execute(" SELECT * FROM `in_support_group` WHERE `User` = :user_id and `Group` = :group_id ", array('user_id' => $user_id, 'group_id' => $group_id) )->rowCount() ){ return true; }else{ return false; } } ////////////////////////////////////////////Methods//////////////////////////////////////////////////// /** * A constructor. * Empty constructor */ public function __construct() { } /** * sets the object's attributes. * @param $values should be an array of the form array('User' => user_id, 'Group' => support_groups_id). */ public function set($values) { $this->setUser($values['User']); $this->setGroup($values['Group']); } /** * creates a new 'in_support_group' entry. * this method will use the object's attributes for creating a new 'in_support_group' entry in the database. */ public function create() { $dbl = new DBLayer("lib"); $query = "INSERT INTO `in_support_group` (`User`,`Group`) VALUES (:user, :group)"; $values = Array('user' => $this->user, 'group' => $this->group); $dbl->execute($query, $values); } /** * deletes an existing 'in_support_group' entry. * this method will use the object's attributes for deleting an existing 'in_support_group' entry in the database. */ public function delete() { $dbl = new DBLayer("lib"); $query = "DELETE FROM `in_support_group` WHERE `User` = :user_id and `Group` = :group_id"; $values = array('user_id' => $this->getUser() ,'group_id' => $this->getGroup()); $dbl->execute($query, $values); } /* public function load($group_id) { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `in_support_group` WHERE `Group` = :group_id", Array('group_id' => $group_id)); $row = $statement->fetch(); $this->set($row); } */ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// /** * get user attribute of the object. */ public function getUser(){ return $this->user; } /** * get group attribute of the object. */ public function getGroup(){ return $this->group; } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// /** * set user attribute of the object. * @param $u integer id of the user */ public function setUser($u){ $this->user = $u; } /** * set group attribute of the object. * @param $g integer id of the support group */ public function setGroup($g){ $this->group = $g; } }