Location: PHPKode > projects > astwebpanel > web/dao/UserGroupDao.php
<?php
/**
 * Copyright (C) 2004 - 2006, John Tarlton.
 *
 * This file is part of AstWebPanel - A web management user interface for Asterisk.
 *
 * AstWebPanel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation. See the LICENSE file distributed
 * with AstWebPanel.
 *
 * Database access object.
 */

require_once('./php/dbase.php');
require_once('./dao/Dao.php');

/* Data Access Object for group configuration.
*/
class UserGroupDao extends DBDao
{
	var $table = 'groups';
	var $data = array('groupid' => '', 'groupname' => '', 'description' => '', 'grouptype' => '', 'partitionid' => '', 'enable' => '');

	function getCount(&$pattern)
	{
		global $db;

		$query = "SELECT count(*) FROM {$this->table} 
                  WHERE groupid IN 
				  (SELECT groupid FROM groupmembers 
				   WHERE userid = (SELECT userid FROM users WHERE username = ?)
                  )";

		$stmt = $db->prepare($query);	
		$querydata = array($pattern[0]['value']);

   		$result = $db->execute($stmt, $querydata);

		$row = $result->fetchRow();
		return $row['count']; 
	}	

	function getMultiple( &$pattern, $offset, $limit, &$values)
	{
		global $db;

		$query = "SELECT * FROM {$this->table} 
			    WHERE groupid IN 
				(SELECT groupid FROM groupmembers 
				 WHERE userid = (SELECT userid FROM users WHERE username = ?) 
			    ) OFFSET ? LIMIT ?"; 			

 		$stmt = $db->prepare($query);	
		$querydata = array($pattern[0]['value'], $offset, $limit);

   		$result = $db->execute($stmt, $querydata); 

        while ($row = $result->fetchRow())
		{
			$values[] = $row;
		}
		$result->free();
	}
}

?>
Return current item: astwebpanel