Model.class.php 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace KIF\Core;
  3. use KIF\Dao\DBAgileDev;
  4. /**
  5. * 定义MVC里的M抽象类,即Model
  6. * @author gaoxiaogang@gmail.com
  7. */
  8. abstract class Model {
  9. /**
  10. * @var KIF\Dao\DBAgileDev
  11. */
  12. protected $objMainDao;
  13. /**
  14. *
  15. * 设置该Model对应的主Dao类
  16. */
  17. abstract protected function setMainDao();
  18. public function __construct() {
  19. $this->setMainDao();
  20. }
  21. public function totals($condtion = null) {
  22. return $this->objMainDao->totals($condtion);
  23. }
  24. public function get($id) {
  25. $result = $this->gets(array($id));
  26. if (!$result) {
  27. return false;
  28. }
  29. return array_pop($result);
  30. }
  31. public function gets(array $ids) {
  32. $result = $this->objMainDao->gets($ids);
  33. return $result;
  34. }
  35. public function getsAll($order = null, $limit = null) {
  36. $ids = $this->objMainDao->getsAllIds($order, $limit);
  37. return $this->gets($ids);
  38. }
  39. }