<?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:22                                      */
/****************************************************************/

class categories_description { 
	public $Conn = 0;
	public $errMsg = '';
	public $errNo= 0;
	public $categories_id=0;
	public $language_id=0;
	public $categories_name=0;

	public function Dodaj(){
		$zwrot=true;
		$query="Insert categories_description (categories_id, language_id, categories_name) VALUES (:categories_id, :language_id, :categories_name) ";
		$sth = $this->Conn->prepare($query);

		$sth->bindParam(':categories_id', $this->categories_id, PDO::PARAM_INT);
		$sth->bindParam(':language_id', $this->language_id, PDO::PARAM_INT);
		$sth->bindParam(':categories_name', $this->categories_name, PDO::PARAM_STR);

		$sth->execute();

		if($sth->errorCode() != 0){
			$zwrot=false;
			$this->errMsg = $sth->errorInfo();
			$this->errNo = $sth->errorCode();
		}

		 return $zwrot;
	 } 
	public function Zmien(){
		$zwrot=true;
		$query="Update categories_description SET categories_name=:categories_name Where categories_id=:categories_id and  language_id=:language_id";
		$sth = $this->Conn->prepare($query);

		$sth->bindParam(':categories_id', $this->categories_id, PDO::PARAM_INT);
		$sth->bindParam(':language_id', $this->language_id, PDO::PARAM_INT);
		$sth->bindParam(':categories_name', $this->categories_name, PDO::PARAM_STR);

		$sth->execute();

		if($sth->errorCode() != 0){
			$zwrot=false;
			$this->errMsg = $sth->errorInfo();
			$this->errNo = $sth->errorCode();
		}

		 return $zwrot;
	 } 
	public function Usun(){
		$zwrot=true;
		$query="Delete from categories_description Where categories_id=:categories_id and  language_id=:language_id";

		$sth = $this->Conn->prepare($query);
		$sth->bindParam(':categories_id', $this->categories_id, PDO::PARAM_INT);
		$sth->bindParam(':language_id', $this->language_id, PDO::PARAM_INT);
		$sth->execute();

		if($sth->errorCode() != 0){
			$zwrot=false;
			$this->errMsg = $sth->errorInfo();
			$this->errNo = $sth->errorCode();
		}

		 return $zwrot;
	 } 
	public function Lista(){
		$query='Select * from categories_description Where categories_name=:categories_name';
		$sth = $this->Conn->prepare($query);
		$sth->bindParam(':categories_name', $this->categories_name, PDO::PARAM_STR);
		$sth->execute();
		$tablica = array();
		$x=0;

		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			foreach ($row as $k => $v)
			{
				$tablica[$x][$k]=trim($v);
			}
			$x++;
		}

		return $tablica;
	}
	public static function Sprawdz($_Name, $_Conn)
	{
		$query='Select categories_id from categories_description Where categories_name=:categories_name';
		$sth = $_Conn->prepare($query);
		$sth->bindParam(':categories_name', $_Name, PDO::PARAM_STR);
		$sth->execute();
		$zwrot=0;

		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$zwrot = $row['categories_id'];			
		}

		return $zwrot;
	}

}
?>
