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

class orders_total { 
	public $Conn = 0;
	public $errMsg = '';
	public $errNo= 0;
	public $orders_total_id=0;
	public $orders_id=0;
	public $title=0;
	public $text=0;
	public $value=0;
	public $class=0;
	public $sort_order=0;

	public function Dodaj(){
		$zwrot=true;
		$query="Insert orders_total (orders_id, title, text, value, class, sort_order) VALUES (:orders_id, :title, :text, :value, :class, :sort_order) ";
		$sth = $this->Conn->prepare($query);

		$sth->bindParam(':orders_id', $this->orders_id, PDO::PARAM_INT);
		$sth->bindParam(':title', $this->title, PDO::PARAM_STR);
		$sth->bindParam(':text', $this->text, PDO::PARAM_STR);
		$sth->bindParam(':value', $this->value, PDO::PARAM_STR);
		$sth->bindParam(':class', $this->class, PDO::PARAM_STR);
		$sth->bindParam(':sort_order', $this->sort_order, PDO::PARAM_INT);

		$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 orders_total SET orders_id=:orders_id, title=:title, text=:text, value=:value, class=:class, sort_order=:sort_order Where orders_total_id=:orders_total_id";
		$sth = $this->Conn->prepare($query);

		$sth->bindParam(':orders_id', $this->orders_id, PDO::PARAM_INT);
		$sth->bindParam(':title', $this->title, PDO::PARAM_STR);
		$sth->bindParam(':text', $this->text, PDO::PARAM_STR);
		$sth->bindParam(':value', $this->value, PDO::PARAM_STR);
		$sth->bindParam(':class', $this->class, PDO::PARAM_STR);
		$sth->bindParam(':sort_order', $this->sort_order, PDO::PARAM_INT);
		$sth->bindParam(':orders_total_id', $this->orders_total_id, PDO::PARAM_INT);

		$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 orders_total Where orders_total_id=:orders_total_id";

		$sth = $this->Conn->prepare($query);
		$sth->bindParam(':orders_total_id', $this->orders_total_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 orders_total Where orders_id=:orders_id';
		$sth = $this->Conn->prepare($query);
		$sth->bindParam(':orders_id', $this->orders_id, PDO::PARAM_INT);
		$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;
	}

}
?>
