item.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. /**
  4. * Created by PhpStorm.
  5. * User: ellisran
  6. * Date: 2016/9/22
  7. * Time: 16:20
  8. */
  9. class Item extends DooModel {
  10. public $itemid;
  11. public $itemname;
  12. public $code;
  13. public $_table = 'fc_item';
  14. public $_primarykey = 'itemid';
  15. public $_fields = array('itemid', 'itemname', 'code');
  16. public function __construct() {
  17. parent::setupModel(__CLASS__);
  18. }
  19. public function getRowbylimit($limit){
  20. return $this->find(array('desc' => 'itemid','limit'=>$limit,'asArray' => TRUE));
  21. }
  22. public function getAllMsg(){
  23. return $this->find(array('select' => 'itemid,itemname','desc' => 'itemid','asArray' => TRUE));
  24. }
  25. public function getRowbyid($id){
  26. return $this->getOne(array('select' => 'itemid,itemname,code', 'where' => 'itemid='.$id, 'asArray' => TRUE));
  27. }
  28. public function getfisrtitemid(){
  29. $item = $this->getOne(array('select' => 'itemid', 'desc' => 'itemid', 'limit' => 1, 'asArray' => TRUE));
  30. return $item['itemid'];
  31. }
  32. public function getnamebyid($id){
  33. $item = $this->getOne(array('select' => 'itemname', 'where' => 'itemid='.$id, 'asArray' => TRUE));
  34. return $item['itemname'];
  35. }
  36. public function getRowbyCode($code){
  37. return $this->getOne(array('select' => 'itemid,itemname,code', 'where' => 'code="'.$code.'"', 'asArray' => TRUE));
  38. }
  39. }