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

include_once("class.database.php");

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

class photos
{ // class : begin


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

var $id;   // KEY ATTR. WITH AUTOINCREMENT

var $user_type;   // (normal Attribute)
var $path;   // (normal Attribute)
var $userid;   // (normal Attribute)

var $database; // Instance of class database


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

function photos()
{

$this->database = new Database();

}


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


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

function getuser_type()
{
return $this->user_type;
}

function getpath()
{
return $this->path;
}

function getuserid()
{
return $this->userid;
}

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


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

function setuser_type($val)
{
$this->user_type =  $val;
}

function setpath($val)
{
$this->path =  $val;
}

function setuserid($val)
{
$this->userid =  $val;
}

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

function select($id)
{

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


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

$this->user_type = $row->user_type;

$this->path = $row->path;

$this->userid = $row->userid;

}





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

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

}

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

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

$sql = "INSERT INTO photos ( user_type,path,userid ) VALUES ( '$this->user_type','$this->path','$this->userid' )";
$result = $this->database->query($sql);
$this->id = mysql_insert_id($this->database->link);

}

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

function update($id)
{



$sql = " UPDATE photos SET  user_type = '$this->user_type',path = '$this->path',userid = '$this->userid' WHERE id = $id ";

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



}
// **********************
// CUSTOM METHOD / LOAD
// **********************
/* Userid*/
function userid($userid)
	{
		$sql =  "SELECT * FROM photos WHERE userid = '$userid';";
		$result =  $this->database->query($sql);
		$result = $this->database->result;
		
		if($row=mysql_fetch_object($result))
		{
			return $row->id;
		}
		else 
		{
			return -1;
		}
	}
/* Userid*/

} // class : end

?>