project.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. Doo::loadModel('pro');
  3. class Project {
  4. private $pro;
  5. public function __construct() {
  6. $this->pro = new Pro();
  7. }
  8. public function insertProject($uid, $pname) {
  9. if (!isset($pname) && $pname)
  10. return FALSE;
  11. $this->pro->uid = filter_var($uid, FILTER_VALIDATE_INT);
  12. $this->pro->pname = filter_var($pname, FILTER_SANITIZE_STRING);
  13. $this->pro->intime = time();
  14. return $this->pro->insert();
  15. }
  16. public function getAll($uid = NULL) {
  17. if (isset($uid)) {
  18. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  19. } else {
  20. return $this->pro->find(array('asArray' => TRUE));
  21. }
  22. }
  23. public function getFewRow($pidstr) {
  24. return $this->pro->find(array('where' => 'pid in(' . $pidstr . ')', 'asArray' => TRUE));
  25. }
  26. public function getRowByPid($pid) {
  27. return $this->pro->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  28. }
  29. // for api
  30. public function getRowUid($uid) {
  31. return $this->pro->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  32. }
  33. public function updateProName($pid, $pname) {
  34. $this->pro->pname = filter_var($pname, FILTER_SANITIZE_STRING);
  35. return $this->pro->update(array('where' => 'pid=?', 'param' => array($pid)));
  36. }
  37. }
  38. ?>