Column.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class Column extends DooModel {
  4. public $cid;
  5. public $title;
  6. public $c_type;
  7. public $link;
  8. public $description;
  9. public $display;
  10. public $_table = 'sc_column';
  11. public $_primarykey = 'cid';
  12. public $_fields = array('cid', 'title', 'c_type', 'link', 'description','display');
  13. function getColumnById($cid = 0) {
  14. return $this->find ( array ( 'where' => 'cid=' . $cid, 'asArray' => TRUE ) );
  15. }
  16. function getColumnByIdList($cid = 0) {
  17. return $this->find ( array ( 'where' => 'cid in ( ' . $cid.' )', 'asArray' => TRUE ) );
  18. }
  19. function getColumnListByType($c_type=1){
  20. $sql = "select * from " . $this->_table . " WHERE `c_type` =" .$c_type;
  21. $query = Doo::db ()->query ( $sql );
  22. $result = $query->fetchAll ();
  23. return $result;
  24. }
  25. function getColumnList($data = array(), $condition = "", $limit = ""){
  26. foreach ( $data as $key => $value ) {
  27. if (is_numeric ( $value ))
  28. $condition .= " and " . $key . " = " . $value;
  29. else
  30. $condition .= " and " . $key . " like '%" . $value . "%' ";
  31. }
  32. $condition = ' where 1 ' . $condition . $limit;
  33. $sql = "select * from " . $this->_table . $condition;
  34. $query = Doo::db ()->query ( $sql );
  35. $result = $query->fetchAll ();
  36. return $result;
  37. }
  38. function deleteColumnByIdList($id){
  39. $id = implode ( ",", $id );
  40. $sql = "delete from " . $this->_table . " where cid in ( " . $id . " ) and c_type !=1";
  41. Doo::db ()->query ( $sql );
  42. }
  43. }
  44. ?>