<?php
/*
*
* -------------------------------------------------------
* CLASSNAME:        weekdays
* GENERATION DATE:  14.01.2014
* FOR MYSQL TABLE:  weekdays
* FOR MYSQL DB:     web-school
* -------------------------------------------------------
* CODE GENERATED BY:
* PHP-MYSQL-CLASS GENERATOR
* -------------------------------------------------------
*
*/

include_once("class.database.php");

// **********************
// CLASS DECLARATION
// **********************

class weekdays
{ // class : begin


// **********************
// ATTRIBUTE DECLARATION
// **********************

var $id;   // KEY ATTR. WITH AUTOINCREMENT

var $days;   // (normal Attribute)
var $status;   // (normal Attribute)

var $database; // Instance of class database


// **********************
// CONSTRUCTOR METHOD
// **********************

function weekdays()
{

$this->database = new Database();

}


// **********************
// GETTER METHODS
// **********************


function getid()
{
return $this->id;
}

function getdays()
{
return $this->days;
}

function getstatus()
{
return $this->status;
}

// **********************
// SETTER METHODS
// **********************


function setid($val)
{
$this->id =  $val;
}

function setdays($val)
{
$this->days =  $val;
}

function setstatus($val)
{
$this->status =  $val;
}

// **********************
// SELECT METHOD / LOAD
// **********************

function select($id)
{

$sql =  "SELECT * FROM weekdays WHERE id = $id;";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);


$this->id = $row->id;

$this->days = $row->days;

$this->status = $row->status;

}





// **********************
// DELETE
// **********************

function delete($id)
{
$sql = "DELETE FROM weekdays WHERE id = $id;";
$result = $this->database->query($sql);

}

// **********************
// INSERT
// **********************

function insert()
{
$this->id = ""; // clear key for autoincrement

$sql = "INSERT INTO weekdays ( days,status ) VALUES ( '$this->days','$this->status' )";
$result = $this->database->query($sql);
$this->id = mysql_insert_id($this->database->link);

}

// **********************
// UPDATE
// **********************

function update($id)
{



$sql = " UPDATE weekdays SET  days = '$this->days',status = '$this->status' WHERE id = $id ";

$result = $this->database->query($sql);



}
// **********************
// SELECT ALL
// **********************

function selectall($cond='',$limit='',$order)
{
	$sql =  "SELECT * FROM weekdays ";
	if($cond!='')
		$sql .= " WHERE $cond ";
	
	if($order!='')
		$sql .= " ORDER BY $order ";
		
	if($limit!='')
		$sql .= " LIMIT $limit ";
	
	$sql .=";";
	
	$result =  $this->database->query($sql);
	$result = $this->database->result;
	$this->rows=array();
	while($row=mysql_fetch_object($result))
	{
	$this->rows[] = $row;
	}
	return $this->rows;
}

// **********************
// CUSTOM METHOD / LOAD
// **********************
function selectworkingdays($day)
{

$sql =  "SELECT * FROM weekdays WHERE days = '$day' ;";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);


$this->id = $row->id;

$this->days = $row->days;

$this->status = $row->status;

}
} // class : end

?>