<?php namespace KIF\Core; use KIF\Dao\DBAgileDev; /** * 定义MVC里的M抽象类,即Model * @author gaoxiaogang@gmail.com */ abstract class Model { /** * @var KIF\Dao\DBAgileDev */ protected $objMainDao; /** * * 设置该Model对应的主Dao类 */ abstract protected function setMainDao(); public function __construct() { $this->setMainDao(); } public function totals($condtion = null) { return $this->objMainDao->totals($condtion); } public function get($id) { $result = $this->gets(array($id)); if (!$result) { return false; } return array_pop($result); } public function gets(array $ids) { $result = $this->objMainDao->gets($ids); return $result; } public function getsAll($order = null, $limit = null) { $ids = $this->objMainDao->getsAllIds($order, $limit); return $this->gets($ids); } }