Product.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class Product extends DooModel {
  4. public $pid;
  5. public $title;
  6. public $fulltitle;
  7. public $content;
  8. public $p_type;
  9. public $logo;
  10. public $link;
  11. public $anid;
  12. public $edition;
  13. public $did;
  14. public $cid;
  15. public $time;
  16. public $orders;
  17. public $_table = 'sc_product';
  18. public $_primarykey = 'pid';
  19. public $_fields = array('pid', 'title','fulltitle', 'content', 'p_type' ,'logo','link','anid', 'edition', 'did', 'cid', 'time','orders');
  20. public function countArchive() {
  21. return $this->count();
  22. }
  23. function getProductByCid($cid = 0 ,$p_type=1){//or p_type=".$p_type." )
  24. return $this->find ( array ('asc' => 'orders', 'where' => 'cid=' . $cid." and p_type!=2 ", 'asArray' => TRUE ) );
  25. }
  26. function getProductByCidAll($cid = 0 ){
  27. return $this->find ( array ('asc' => 'orders', 'where' => ' cid=' . $cid." and p_type!=3 ", 'asArray' => TRUE ) );
  28. }
  29. function getProductById($pid = 0 ) {
  30. return $this->find ( array ('asc' => 'time', 'where' => 'pid=' . $pid, 'asArray' => TRUE ) );
  31. }
  32. function getProductList($data = array(), $condition = "", $limit = ""){
  33. foreach ( $data as $key => $value ) {
  34. if (is_numeric ( $value ))
  35. $condition .= " and " . $key . " = " . $value;
  36. else
  37. $condition .= " and " . $key . " like '%" . $value . "%' ";
  38. }
  39. $condition = ' where 1 ' . $condition . $limit;
  40. $sql = "select * from " . $this->_table . $condition;
  41. $query = Doo::db ()->query ( $sql );
  42. $result = $query->fetchAll ();
  43. return $result;
  44. }
  45. function deleteProductByIdList($id){
  46. $id = implode ( ",", $id );
  47. $sql = "delete from " . $this->_table . " where pid in ( " . $id . " )";
  48. Doo::db ()->query ( $sql );
  49. }
  50. }
  51. ?>