<?php
/**
 * Class that operate on table 'usergroup'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2013-04-06 10:57
 */
class UsergroupMySqlExtDAO extends UsergroupMySqlDAO{

		public function loadusergroupname($id){
		$sql = 'SELECT usergroupname FROM usergroup WHERE usergroupid = ?';
		$sqlQuery = new SqlQuery($sql);
		$sqlQuery->setNumber($id);
		return $this->querySingleResult($sqlQuery);
	}
	
	public function updateDel($usergroup){
		$sql = 'UPDATE usergroup SET currentdate = ?, conditions = ? WHERE usergroupid = ?';
		$sqlQuery = new SqlQuery($sql);
		
		$sqlQuery->set($usergroup->currentdate);
		$sqlQuery->setNumber($usergroup->conditions);

		$sqlQuery->setNumber($usergroup->usergroupid);
		return $this->executeUpdate($sqlQuery);
	}
	
	
	
	public function queryAllwithOrder(){
		$sql = 'SELECT * FROM usergroup order by usergroupid desc';
		$sqlQuery = new SqlQuery($sql);
		return $this->getList($sqlQuery);
	}
	

	public function queryAllnotdeleted(){
		$sql = 'SELECT * FROM usergroup where conditions=0 order by usergroupid desc';
		$sqlQuery = new SqlQuery($sql);
		return $this->getList($sqlQuery);
	}
	
	
	public function queryAllWithName($usergroupname)
	{
		$sql = 'SELECT * FROM usergroup WHERE usergroupname ="'.$usergroupname.'"';
		$sqlQuery = new SqlQuery($sql);
		return $this->getRow($sqlQuery);
	}
	
	
	
	
	public function deletetemp($usergroupid){
		$sql = 'UPDATE usergroup SET conditions = 1 WHERE usergroupid = ?';
		$sqlQuery = new SqlQuery($sql);

		$sqlQuery->setNumber($usergroupid);
		return $this->executeUpdate($sqlQuery);
	}



	
	public function returndelete($usergroupid){
		$sql = 'UPDATE usergroup SET conditions = 0 WHERE usergroupid = ?';
		$sqlQuery = new SqlQuery($sql);

		$sqlQuery->setNumber($usergroupid);
		return $this->executeUpdate($sqlQuery);
	}

   
   
   public function queryAllnotin($usersgroupids){
		$sql = 'SELECT * FROM usergroup where
		 conditions=0 
		 and usergroupid not in('.$usersgroupids.')
		 order by usergroupid desc';
		$sqlQuery = new SqlQuery($sql);
		return $this->getList($sqlQuery);
	}
	
	
	  public function queryAllarein($usersgroupids){
		$sql = 'SELECT * FROM usergroup where
		 conditions=0 
		 and usergroupid in('.$usersgroupids.')
		 order by usergroupid desc';
		$sqlQuery = new SqlQuery($sql);
		return $this->getList($sqlQuery);
	}
	

}
?>