| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- namespace common\base\classes;
- use Yii;
- use \common\base\models\Base;
- class BaseClass
- {
- public static $baseFile;
- //查询全部 ssh 2019.11.27
- public static function getAllList($select, $where, $order = '', $with = '')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- $return = $model->getAllList($select, $where, $order, $with);
- return $return;
- }
- //分页查询 ssh 2019.9.21
- public static function getList($select, $where, $order = '', $with = '')
- {
- /** @var Base $model */
- $get = Yii::$app->request->get();
- $page = isset($get['page']) ? $get['page'] : 1;
- Yii::$app->params['page'] = $page;
- $pageSize = isset($get['pageSize']) && !empty($get['pageSize']) ? $get['pageSize'] : Yii::$app->params['pageSize'];
- $model = Yii::createObject(['class' => static::$baseFile]);
- $return = $model->getList($select, $where, $page, $pageSize, $order, $with);
- return $return;
- }
- //查询指定条数 ssh 2019.11.30
- public static function getLimitList($select, $where, $limit = 10, $order = '', $with = '')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- $return = $model->getLimitList($select, $where, $limit, $order, $with);
- return $return;
- }
- public static function add($data, $returnObject = false)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->add($data, $returnObject);
- }
- /**
- * 批量添加
- */
- public static function batchAdd($data)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- $model->batchAdd($data);
- }
- /**
- * 根据主键ID删除一条记录
- */
- public static function deleteById($id)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->deleteById($id);
- }
- /**
- *根据条件删除一条或多条记录
- */
- public static function deleteByCondition($condition)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- $count = $model->deleteByCondition($condition);
- return $count;
- }
- //根据id批量删 ssh 2019.12.7
- public static function deleteByIds($ids)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->deleteByIds($ids);
- }
- /**
- * 根据主键ID更新一条记录
- */
- public static function updateById($id, $data)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->updateById($id, $data);
- }
- //根据多个主键id更新 ssh 2019.9.3
- public static function updateByIds($ids, $data)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->updateByIds($ids, $data);
- }
- /**
- * 根据条件更新一条或多条记录
- */
- public static function updateByCondition($condition, $data)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- $count = $model->updateByCondition($condition, $data);
- return $count;
- }
- /**
- * 根据主键ID查出一条记录
- */
- public static function getById($id, $returnObject = false, $field = '*')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getById($id, $returnObject, $field);
- }
- //随机取一个 ssh 2020.2.10
- public static function getOne($returnObject = false, $order = false, $field = '*')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getOne($returnObject, $order, $field);
- }
- /**
- *根据条件查出一条记录
- */
- public static function getByCondition($condition, $returnObject = false, $order = false, $field = '*')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getByCondition($condition, $returnObject, $order, $field);
- }
- //是否存在 ssh 2019.8.30
- public static function exists($condition)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->exists($condition);
- }
- /**
- *根据条件查出多条记录
- */
- public static function getAllByCondition($condition, $order = null, $field = '*', $indexBy = null, $returnObject = false)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getAllByCondition($condition, $order, $field, $indexBy, $returnObject);
- }
- /**
- * 根据多个主键ID查询多条记录
- */
- public static function getByIds($ids, $order = null, $indexBy = null, $field = '*')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getByIds($ids, $order, $indexBy, $field);
- }
- /**
- *根据条件查出数量
- */
- public static function getCount($condition)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getCount($condition);
- }
- //计数器+1-1 shizq 2019-12-05
- public static function counters($counters, $condition, $params = [])
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->counters($counters, $condition, $params);
- }
- //根据主键获取被销的信息 ssh 2021.5.18
- public static function getLockById($id, $field = '*')
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->getLockById($id, $field);
- }
- //求和
- public static function sum($condition, $field)
- {
- /** @var Base $model */
- $model = Yii::createObject(['class' => static::$baseFile]);
- return $model->sum($condition, $field);
- }
- }
|