project.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. Doo::loadModel('pro');
  3. class Project
  4. {
  5. private $pro;
  6. public function __construct()
  7. {
  8. $this->pro = new Pro();
  9. }
  10. public function insertProject($uid, $pname, $switch_change)
  11. {
  12. if (!isset($pname) && $pname)
  13. return FALSE;
  14. $this->pro->uid = filter_var($uid, FILTER_VALIDATE_INT);
  15. $this->pro->pname = filter_var($pname, FILTER_SANITIZE_STRING);
  16. $this->pro->intime = time();
  17. $this->pro->switch_change = $switch_change;
  18. return $this->pro->insert();
  19. }
  20. public function getAll($uid = NULL)
  21. {
  22. if (isset($uid)) {
  23. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  24. } else {
  25. return $this->pro->find(array('asArray' => TRUE));
  26. }
  27. }
  28. public function getFewRow($pidstr)
  29. {
  30. return $this->pro->find(array('where' => 'pid in(' . $pidstr . ')', 'asArray' => TRUE));
  31. }
  32. public function getRowByPid($pid)
  33. {
  34. return $this->pro->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  35. }
  36. // for api
  37. public function getRowUid($uid)
  38. {
  39. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  40. }
  41. public function updateProName($pid, $pname, $switch_change)
  42. {
  43. $this->pro->pname = filter_var($pname, FILTER_SANITIZE_STRING);
  44. $this->pro->switch_change = $switch_change;
  45. return $this->pro->update(array('where' => 'pid=?', 'param' => array($pid)));
  46. }
  47. public function del($pid)
  48. {
  49. return $this->pro->delete(array('where' => 'pid=?', 'param' => array($pid)));
  50. }
  51. public function getswitchChange($pid)
  52. {
  53. $result = $this->pro->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  54. return $result['switch_change'];
  55. }
  56. }
  57. ?>