Storecost.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Storecost extends BaseModel {
  15. public $page_info;
  16. /**
  17. * 读取列表
  18. * @access public
  19. * @author csdeshang
  20. * @param array $condition 条件
  21. * @param int $pagesize 分页
  22. * @param string $order 排序
  23. * @param string $field 字段
  24. * @return array
  25. */
  26. public function getStorecostList($condition, $pagesize = '', $order = '', $field = '*') {
  27. if($pagesize){
  28. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  29. $this->page_info = $result;
  30. return $result->items();
  31. }else{
  32. $result = Db::name('storecost')->field($field)->where($condition)->order($order)->select()->toArray();
  33. return $result;
  34. }
  35. }
  36. /**
  37. * 读取单条记录
  38. * @access public
  39. * @author csdeshang
  40. * @param array $condition 条件
  41. * @param string $fields 字段
  42. * @return array
  43. */
  44. public function getStorecostInfo($condition, $fields = '*') {
  45. $result = Db::name('storecost')->where($condition)->field($fields)->find();
  46. return $result;
  47. }
  48. /**
  49. * 增加
  50. * @access public
  51. * @author csdeshang
  52. * @param array $data 数据
  53. * @return bool
  54. */
  55. public function addStorecost($data) {
  56. return Db::name('storecost')->insertGetId($data);
  57. }
  58. /**
  59. * 删除
  60. * @access public
  61. * @author csdeshang
  62. * @param array $condition 条件
  63. * @return bool
  64. */
  65. public function delStorecost($condition) {
  66. return Db::name('storecost')->where($condition)->delete();
  67. }
  68. /**
  69. * 更新
  70. * @access public
  71. * @author csdeshang
  72. * @param array $data 更新数据
  73. * @param array $condition 条件
  74. * @return bool
  75. */
  76. public function editStorecost($data, $condition) {
  77. return Db::name('storecost')->where($condition)->update($data);
  78. }
  79. }