Location: PHPKode > scripts > GalleryShuffle > v1.0/php/Models/classicTable.php
<?php

/**
* CLASSIC TABLE
**/

class model_classicTable
{

	protected $tableName;
	
	public function __construct($tableName)
	{
	
		$this->tableName = $tableName;
		
	}
	
	public function getAll()
	{
	
		return DB::qry("SELECT * FROM `" . $this->tableName . "`", 3);
		
	}
	
	public function getLineById($id)
	{
	
		return DB::qry("SELECT * FROM `" . $this->tableName . "` WHERE ID=" . $id, 2);
		
	}
	
	public function deleteLineById($id)
	{
	
		DB::qry("DELETE FROM `" . $this->tableName . "` WHERE ID=" . $id);
		
	}
	
	protected function insertNewLine($params, $isActive=NULL)
	{
		
		if($this->getSetIsActive($isActive)) $params .= $this->getSetIsActive($isActive);
		
		DB::qry($req = "INSERT INTO `" . $this->tableName . "` SET " . $params . ",
		`ID`='',
		`date_created`='" . FUNCTIONS::getCurrentDateTime() . "',
		`date_modified`='" . FUNCTIONS::getCurrentDateTime() . "'
		");
		
	}
	
	protected function updateLineById($id, $params=NULL, $isActive=NULL)
	{
		
		if($this->getSetIsActive($isActive)) $params .= $this->getSetIsActive($isActive);
		if($params != NULL) $params .= ",";
		
		DB::qry($req = "UPDATE `" . $this->tableName . "` SET " . $params . "
		`date_modified`='" . FUNCTIONS::getCurrentDateTime() . "' 
		WHERE `ID`=" . $id);
		
	}
	
	private function getSetIsActive($isActive)
	{
	
		if($isActive != NULL) {
			$isActive = FUNCTIONS::getTinyIntFromCheckbox($isActive);
			return ", `is_active`='" . $isActive . "'";
		}
	
	}
	
}

?>
Return current item: GalleryShuffle