Paramore
- Paramore 赞了回答
$rows = (new \yii\db\Query()) ->from('admin') ->where("status=:status and (username like :keyword or `name` like :keyword )") ->addParams([':status'=>1,':keyword'=>'%陈%']) ->all();
参考下,个人认为,如果语句复杂,用原生sql语句也没有不行的,毕竟它本身就支持,返回的是数组
- Paramore 赞了回复
那具体应该怎么写呢
这是我修改后的 views/layouts/main.php 文件 你参考下吧
<?php /* @var $this \yii\web\View */ /* @var $content string */ use yii\helpers\Html; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use app\assets\AppAsset; ?> <?php $this->beginPage() ?> <!DOCTYPE html> <html lang="<?= Yii::$app->language ?>"> <head> <meta charset="<?= Yii::$app->charset ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?= Html::csrfMetaTags() ?> <title><?= Html::encode($this->title) ?></title> <?php $this->head() ?> </head> <body> <?php $this->beginBody() ?> <div class="wrap"> <?= $content ?> </div> </div> <?php $this->endBody() ?> </body> </html> <?php $this->endPage() ?>
感谢两位! 我明白了!
- Paramore 赞了回复
取消layout,需在自己在view中实现 head 部分, asset 需要先实现head部分才能引入。 在layout 中你可以看到 <?php $this->head() ?>
- Paramore 赞了回复
$layout = false;
意思是不引用模板 就不能使用该模板引用的样式和js 代表该页面需要重新引用所有css和js - Paramore 2016-04-20 已签到连续签到1天,获得了5个金钱