Yii2 Query Where

https://blog.csdn.net/hzqghost/article/details/44117081

where('status=1')->
where('status=:status', [':status' => $status])->
where([
    'status' => 10,
    'type' => null,
    'id' => [4, 8, 15],
])->
-------
$userQuery = (new Query())->select('id')->from('user');
// ...WHERE `id` IN (SELECT `id` FROM `user`)
$query->...->where(['id' => $userQuery])->...
--------
['and', 'id=1', 'id=2'] //id=1 AND id=2
['and', 'type=1', ['or', 'id=1', 'id=2']] //type=1 AND (id=1 OR id=2)
['between', 'id', 1, 10] //id BETWEEN 1 AND 10
['not between', 'id', 1, 10] //not id BETWEEN 1 AND 10
['in', 'id', [1, 2, 3]] //id IN (1, 2, 3)
['not in', 'id', [1, 2, 3]] //not id IN (1, 2, 3)
['like', 'name', 'tester'] //name LIKE '%tester%'
['like', 'name', ['test', 'sample']] //name LIKE '%test%' AND name LIKE '%sample%'
['not like', 'name', ['or', 'test', 'sample']] //not name LIKE '%test%' OR not name LIKE '%sample%'
['exists','id', $userQuery] //EXISTS (sub-query) | not exists
['>', 'age', 10] //age>10

Yii2 disable Jquery Asset

在项目中经常碰到前端组件需要使用的jQuery版本较低,而yii2集成的JqueryAsset里的jQuery版本较高,只能手动引入自己需要的jQuery。但是发现无论怎么禁用JqueryAsset仍然被重复使用,导致页面的jQuery重复加载,而且版本不同,自然是不行的。

方法1:打开yii的debug条,找到是哪个页面引用的JqueryAsset,去掉就好,如果是官方引用,不好直接修改,使用方法2

方法2:在config.php的components段,添加如下代码即可全局禁用JqueryAsset

'assetManager' => [
    'bundles' => [
        'yii\web\JqueryAsset' => [
            'sourcePath' => null,
            'js' => [],
        ],
    ],
],

吐槽一下官方的JqueryAsset加载的是未压缩过的jquery,综上,还是建议禁用后手动引入自己需要的jQuery.