<?php
Doo::loadCore ( 'db/DooModel' );
class accountItem extends DooModel {
	public $aid;
	public $category;
	public $name;
	public $_table = 'CLD_accountItem';
	public $_primarykey = 'aid';
	public $_fields = array (
			'aid',
			'category',
			'name' 
	);
	
	/**
	 * 
	 */
	function getAccountItem(){
		$sql = 'select category
				from ' . $this->_table . '
						 GROUP BY category ORDER BY  aid ASC  ';
		$query = Doo::db ()->query ( $sql );
		$itemCategory = $query->fetchAll ();
		
		$list = $this->find ( array (
				'asArray' => TRUE
		) );
		
		$acctionItem=array();
		foreach ($itemCategory as $key=>$value){
			$acctionItem[$value['category']]=array();
			foreach ($list as $k=>$v){
				if ($value['category']==$v['category']){
					array_push($acctionItem[$value['category']], $v);
				}
			}
		}
		
		return $acctionItem;
	}
}

?>