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

include_once("class.database.php");

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

class std_category
{ // class : begin


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

var $id;   // KEY ATTR. WITH AUTOINCREMENT

var $std_category;   // (normal Attribute)
var $org_id;   // (normal Attribute)

var $database; // Instance of class database


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

function std_category()
{

$this->database = new Database();

}


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


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

function getstd_category()
{
return $this->std_category;
}

function getorg_id()
{
return $this->org_id;
}

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


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

function setstd_category($val)
{
$this->std_category =  $val;
}

function setorg_id($val)
{
$this->org_id =  $val;
}

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

function select($id)
{
$org_id=$_SESSION['org_id'];
$sql =  "SELECT * FROM std_category WHERE id = $id AND  org_id = $org_id";
$result =  $this->database->query($sql);
$result = $this->database->result;
$row = mysql_fetch_object($result);


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

$this->std_category = $row->std_category;

$this->org_id = $row->org_id;

}





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

function delete($id)
{
	$org_id=$_SESSION['org_id'];
$sql = "DELETE FROM std_category WHERE id = $id AND org_id = $org_id;";
$result = $this->database->query($sql);

}

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

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

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

}

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

function update($id)
{


$org_id=$_SESSION['org_id'];
$sql = " UPDATE std_category SET  std_category = '$this->std_category',org_id = '$this->org_id' WHERE id = $id AND  org_id = $org_id";

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



}
// **********************
// CUSTOM METHOD / LOAD
// **********************

/*Org Select all*/
function selectorgall()
{
	$org_id=$_SESSION['org_id'];
	$sql =  "SELECT * FROM std_category WHERE org_id='$org_id' ";
	$result =  $this->database->query($sql);
	$result = $this->database->result;
	$this->rows=array();
	while($row=mysql_fetch_object($result))
	{
	$this->rows[] = $row;
	}
	return $this->rows;
}
/*Org Select all*/
/*  Check std_category */
 function check_stdcat($id)
	{
		$org_id=$_SESSION['org_id'];
		$sql =  "SELECT * FROM std_category WHERE id = '$id' AND org_id='$org_id';";
		//die($sql);
		$result =  $this->database->query($sql);
		$result = $this->database->result;
		if($row=mysql_fetch_object($result))
		{
			return $row->id;
		}
		else 
		{
			return -1;
		}
	}
	/*  Check std_category */
} // class : end

?>