<?php 
/****************************************************************/
/*          e-mo.pl © 2017                                      */
/*          http://www.e-mo.com.pl                              */
/*          e-mail: info@e-mo.pl                                */
/*          produkt: Action2osCommerce                          */
/*          wersja: 1.9.7                                       */
/*          webserwis: oscGold                                  */
/*          sciezka: https://www.e-mo.com.pl/plikit,1918,533545b244d7d.php*/
/*          data: 2017-09-25                                    */
/*          godz: 10:45:25                                      */
/****************************************************************/

class jm { 
	public $Conn = 0;
	public $errMsg = '';
	public $errNo= 0;
	public $tax_rates_id=0;
	public $tax_zone_id=0;
	public $tax_class_id=0;
	public $tax_priority=0;
	public $tax_rate=0;
	public $tax_description=0;
	public $last_modified=0;
	public $date_added=0;

	public static function Szukaj($_jm, $_lang, $_Conn)
	{
		$zwrot=0;
		$query="Select products_jm_id from products_jm Where language_id=:lang and products_jm_name=:jm";

		$sth = $_Conn->prepare($query);
		$sth->bindParam(':jm', $_jm, PDO::PARAM_STR);
		$sth->bindParam(':lang', $_lang, PDO::PARAM_INT);

		$sth->execute();

		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{			
			$zwrot=$row['products_jm_id'];			
		}
		
		if($zwrot == 0)
		{
			$query="Insert INTO products_jm (language_id, products_jm_name, date_added, last_modified) VALUES (:lang, :jm, now(), now())";

			$sth = $_Conn->prepare($query);
			$sth->bindParam(':jm', $_jm, PDO::PARAM_STR);
			$sth->bindParam(':lang', $_lang, PDO::PARAM_INT);
			$sth->execute();

			$zwrot=$_Conn->lastInsertId(); 
		}

		return $zwrot;
	 } 

}
?>
