project.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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)
  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. return $this->pro->insert();
  18. }
  19. public function getAll($uid = NULL)
  20. {
  21. if (isset($uid)) {
  22. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  23. } else {
  24. return $this->pro->find(array('asArray' => TRUE));
  25. }
  26. }
  27. public function getFewRow($pidstr)
  28. {
  29. return $this->pro->find(array('where' => 'pid in(' . $pidstr . ')', 'asArray' => TRUE));
  30. }
  31. public function getRowByPid($pid)
  32. {
  33. return $this->pro->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  34. }
  35. // for api
  36. public function getRowUid($uid)
  37. {
  38. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  39. }
  40. public function updateProName($pid, $pname)
  41. {
  42. $this->pro->pname = filter_var($pname, FILTER_SANITIZE_STRING);
  43. return $this->pro->update(array('where' => 'pid=?', 'param' => array($pid)));
  44. }
  45. public function del($pid)
  46. {
  47. return $this->pro->delete(array('where' => 'pid=?', 'param' => array($pid)));
  48. }
  49. }
  50. ?>