BaseClass.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace biz\base\classes;
  3. use Yii;
  4. class BaseClass
  5. {
  6. public static $baseFile;
  7. //查询全部 shish 2019.11.27
  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 getList($select, $where, $page, $pageSize, $order = '', $with = '')
  16. {
  17. $model = Yii::createObject(['class' => static::$baseFile]);
  18. $return = $model->getList($select, $where, $page, $pageSize, $order, $with);
  19. return $return;
  20. }
  21. public static function add($data, $returnObject = false)
  22. {
  23. $model = Yii::createObject(['class' => static::$baseFile]);
  24. return $model->add($data, $returnObject);
  25. }
  26. /**
  27. * 批量添加
  28. */
  29. public static function batchAdd($data)
  30. {
  31. $model = Yii::createObject(['class' => static::$baseFile]);
  32. $model->batchAdd($data);
  33. }
  34. /**
  35. * 根据主键ID删除一条记录
  36. */
  37. public static function deleteById($id)
  38. {
  39. $model = Yii::createObject(['class' => static::$baseFile]);
  40. return $model->deleteById($id);
  41. }
  42. /**
  43. *根据条件删除一条或多条记录
  44. */
  45. public static function deleteByCondition($condition)
  46. {
  47. $model = Yii::createObject(['class' => static::$baseFile]);
  48. $count = $model->deleteByCondition($condition);
  49. return $count;
  50. }
  51. /**
  52. * 根据主键ID更新一条记录
  53. */
  54. public static function updateById($id, $data)
  55. {
  56. $model = Yii::createObject(['class' => static::$baseFile]);
  57. return $model->updateById($id, $data);
  58. }
  59. //根据多个主键id更新 shish 2019.9.3
  60. public static function updateByIds($ids, $data)
  61. {
  62. $model = Yii::createObject(['class' => static::$baseFile]);
  63. return $model->updateByIds($ids, $data);
  64. }
  65. /**
  66. * 根据条件更新一条或多条记录
  67. */
  68. public static function updateByCondition($condition, $data)
  69. {
  70. $model = Yii::createObject(['class' => static::$baseFile]);
  71. $count = $model->updateByCondition($condition, $data);
  72. return $count;
  73. }
  74. /**
  75. * 根据主键ID查出一条记录
  76. */
  77. public static function getById($id, $returnObject = false)
  78. {
  79. $model = Yii::createObject(['class' => static::$baseFile]);
  80. return $model->getById($id, $returnObject);
  81. }
  82. /**
  83. *根据条件查出一条记录
  84. */
  85. public static function getByCondition($condition, $returnObject = false, $order = false)
  86. {
  87. $model = Yii::createObject(['class' => static::$baseFile]);
  88. return $model->getByCondition($condition, $returnObject, $order);
  89. }
  90. //是否存在 shish 2019.8.30
  91. public static function exists($condition)
  92. {
  93. $model = Yii::createObject(['class' => static::$baseFile]);
  94. return $model->exists($condition);
  95. }
  96. /**
  97. *根据条件查出多条记录
  98. */
  99. public static function getAllByCondition($condition, $order = null, $field, $indexBy = null)
  100. {
  101. $model = Yii::createObject(['class' => static::$baseFile]);
  102. return $model->getAllByCondition($condition, $order, $field, $indexBy);
  103. }
  104. /**
  105. * 根据多个主键ID查询多条记录
  106. */
  107. public static function getByIds($ids, $order = null, $indexBy = null)
  108. {
  109. $model = Yii::createObject(['class' => static::$baseFile]);
  110. return $model->getByIds($ids, $order, $indexBy);
  111. }
  112. /**
  113. *根据条件查出数量
  114. */
  115. public static function getCount($condition)
  116. {
  117. $model = Yii::createObject(['class' => static::$baseFile]);
  118. return $model->getCount($condition);
  119. }
  120. }