BaseClass.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace biz\base\classes;
  3. use Yii;
  4. class BaseClass
  5. {
  6. public static $baseFile;
  7. //没有分页
  8. public static function getAllList($select, $where, $order = '', $with = '')
  9. {
  10. $model = Yii::createObject(['class' => static::$baseFile]);
  11. $return = $model->getAllList($select, $where, $order, $with);
  12. return $return;
  13. }
  14. //分页查询返回数据 shish 2019.9.21
  15. public static function getListData($select, $where, $page, $pageSize, $order = '', $with = '')
  16. {
  17. $model = Yii::createObject(['class' => static::$baseFile]);
  18. $return = $model->getListData($select, $where, $page, $pageSize, $order, $with);
  19. return $return;
  20. }
  21. //分页查询返回json形式 shish 2019.9.21
  22. public static function getList($select, $where, $page, $pageSize, $order = '', $with = '')
  23. {
  24. $model = Yii::createObject(['class' => static::$baseFile]);
  25. $return = $model->getList($select, $where, $page, $pageSize, $order, $with);
  26. return $return;
  27. }
  28. /**
  29. * 后台专用的获取列表 shish 2019.8.18
  30. */
  31. public static function getBackendList($select, $where, $page, $pageSize, $order = '', $with = '')
  32. {
  33. $model = Yii::createObject(['class' => static::$baseFile]);
  34. $return = $model->getBackendList($select, $where, $page, $pageSize, $order, $with);
  35. return $return;
  36. }
  37. public static function add($data, $returnObject = false)
  38. {
  39. $model = Yii::createObject(['class' => static::$baseFile]);
  40. return $model->add($data, $returnObject);
  41. }
  42. /**
  43. * 批量添加
  44. */
  45. public static function batchAdd($data)
  46. {
  47. $model = Yii::createObject(['class' => static::$baseFile]);
  48. $model->batchAdd($data);
  49. }
  50. /**
  51. * 根据主键ID删除一条记录
  52. */
  53. public static function deleteById($id)
  54. {
  55. $model = Yii::createObject(['class' => static::$baseFile]);
  56. return $model->deleteById($id);
  57. }
  58. /**
  59. *根据条件删除一条或多条记录
  60. */
  61. public static function deleteByCondition($condition)
  62. {
  63. $model = Yii::createObject(['class' => static::$baseFile]);
  64. $count = $model->deleteByCondition($condition);
  65. return $count;
  66. }
  67. /**
  68. * 根据主键ID更新一条记录
  69. */
  70. public static function updateById($id, $data)
  71. {
  72. $model = Yii::createObject(['class' => static::$baseFile]);
  73. return $model->updateById($id, $data);
  74. }
  75. //根据多个主键id更新 shish 2019.9.3
  76. public static function updateByIds($ids, $data)
  77. {
  78. $model = Yii::createObject(['class' => static::$baseFile]);
  79. return $model->updateByIds($ids, $data);
  80. }
  81. /**
  82. * 根据条件更新一条或多条记录
  83. */
  84. public static function updateByCondition($condition, $data)
  85. {
  86. $model = Yii::createObject(['class' => static::$baseFile]);
  87. $count = $model->updateByCondition($condition, $data);
  88. return $count;
  89. }
  90. /**
  91. * 根据主键ID查出一条记录
  92. */
  93. public static function getById($id, $returnObject = false)
  94. {
  95. $model = Yii::createObject(['class' => static::$baseFile]);
  96. return $model->getById($id, $returnObject);
  97. }
  98. /**
  99. *根据条件查出一条记录
  100. */
  101. public static function getByCondition($condition, $returnObject = false, $order = false)
  102. {
  103. $model = Yii::createObject(['class' => static::$baseFile]);
  104. return $model->getByCondition($condition, $returnObject, $order);
  105. }
  106. //是否存在 shish 2019.8.30
  107. public static function exists($condition)
  108. {
  109. $model = Yii::createObject(['class' => static::$baseFile]);
  110. return $model->exists($condition);
  111. }
  112. /**
  113. *根据条件查出多条记录
  114. */
  115. public static function getAllByCondition($condition, $order = null, $field, $indexBy = null)
  116. {
  117. $model = Yii::createObject(['class' => static::$baseFile]);
  118. return $model->getAllByCondition($condition, $order, $field, $indexBy);
  119. }
  120. /**
  121. * 根据多个主键ID查询多条记录
  122. */
  123. public static function getByIds($ids, $order = null, $indexBy = null)
  124. {
  125. $model = Yii::createObject(['class' => static::$baseFile]);
  126. return $model->getByIds($ids, $order, $indexBy);
  127. }
  128. /**
  129. *根据条件查出数量
  130. */
  131. public static function getCount($condition)
  132. {
  133. $model = Yii::createObject(['class' => static::$baseFile]);
  134. return $model->getCount($condition);
  135. }
  136. }