|
|
@@ -239,6 +239,8 @@ class Base extends ActiveRecord
|
|
|
* 'name' => 'john', // 等于
|
|
|
* 'id>' => 3, // 大于
|
|
|
* 'id<' => 10, // 小于
|
|
|
+ * 'id>=' => 3, // 大于等于
|
|
|
+ * 'id<=' => 10, // 小于等于
|
|
|
* 'id!=' => -1, // 不等于
|
|
|
* 'id' => ['in', [10,11,12]], // IN
|
|
|
* 'id' => ['not in', [10,11,12]], // NOT IN
|
|
|
@@ -261,13 +263,23 @@ class Base extends ActiveRecord
|
|
|
$pos = strpos($key, '!=');
|
|
|
$currentKey = substr($key, 0, $pos);
|
|
|
$param = ['!=', $currentKey, $val];
|
|
|
+ } elseif (strstr($key, '>=')) {
|
|
|
+ //大于等于
|
|
|
+ $pos = strpos($key, '>=');
|
|
|
+ $currentKey = substr($key, 0, $pos);
|
|
|
+ $param = ['>=', $currentKey, $val];
|
|
|
+ } elseif (strstr($key, '<=')) {
|
|
|
+ //小于等于
|
|
|
+ $pos = strpos($key, '<=');
|
|
|
+ $currentKey = substr($key, 0, $pos);
|
|
|
+ $param = ['<=', $currentKey, $val];
|
|
|
} elseif (strstr($key, '>')) {
|
|
|
- //暂不支持大于等于,等于请使用between
|
|
|
+ //大于
|
|
|
$pos = strpos($key, '>');
|
|
|
$currentKey = substr($key, 0, $pos);
|
|
|
$param = ['>', $currentKey, $val];
|
|
|
} elseif (strstr($key, '<')) {
|
|
|
- //暂不支持小于等于,等于请使用between
|
|
|
+ //小于
|
|
|
$pos = strpos($key, '<');
|
|
|
$currentKey = substr($key, 0, $pos);
|
|
|
$param = ['<', $currentKey, $val];
|
|
|
@@ -467,17 +479,6 @@ class Base extends ActiveRecord
|
|
|
return self::updateAllCounters($counters, $condition, $params);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取图书的作者
|
|
|
- * @return \yii\db\ActiveQuery
|
|
|
- * @note 此方法疑似为示例代码,建议检查
|
|
|
- */
|
|
|
- public function getAuthor()
|
|
|
- {
|
|
|
- //同样第一个参数指定关联的子表模型类名
|
|
|
- return $this->hasOne(Author::className(), ['id' => 'author_id']);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 根据主键获取记录并锁定 (SELECT FOR UPDATE)
|
|
|
* @param int|string $id 主键ID
|