Well this is a working version of the AutoAssign Class.
Database stay the same, added some indexes.
<?php
/*********************************************************************
class.assign.php
**********************************************************************/
class Assign{
var $id;
var $email;
var $created;
var $updated;
var $staff_id;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function Assign($email){
$this->load($email);
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function create($staff_id,$email)
{
$sql= 'INSERT INTO '.TICKET_AUTO_ASSIGN_TABLE.' SET created=NOW() '.
', email='.db_input($email).
', staff_id='.db_input($staff_id);
return (db_query($sql) && ($id=db_insert_id()))?$id;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function load($email) {
$sql =' SELECT * FROM '.TICKET_AUTO_ASSIGN_TABLE. ' WHERE email='.db_input($email);
if(($res=db_query($sql)) && db_num_rows($res)):
$row=db_fetch_array($res);
$this->id =$row;
$this->email =$row;
$this->created =$row;
$this->updated =$row;
$this->staff_id =$row;
$this->row=$row;
return true;
endif;
return false;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getStaffId() {
return $this->staff_id;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getEmail() {
return $this->email;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function getId() {
return $this->id;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function setStaff($staffId) {
$sql= 'UPDATE '.TICKET_AUTO_ASSIGN_TABLE.' SET staff_id='.db_input($staffId).' WHERE auto_assign_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
function exist($email) {
return db_num_rows(db_query('SELECT auto_assign_id FROM '.TICKET_AUTO_ASSIGN_TABLE.' WHERE email='.db_input($email)))?true;
}
}
?>