随笔分类 - YII2
摘要:在views/news/_copyright.php中插入以下代码: This is text about copyright data for news items然后在同级目录中的itemsList.php中输入context->renderPartial('_copyright'); ?...
阅读全文
摘要:首先在app\controllers下建立TestController.php,内容为如下代码: 1 request->isPost) {14 $file = UploadedFile::getInstance($model, 'file');15 ...
阅读全文
摘要:1 'yii\filters\PageCache', //页面缓存11 'duration'=>1000,//缓存时间12 'only'=>['index','test'], //缓存的页面13 'de...
阅读全文
摘要:首先在controller中直接执行return $this->renderPartial('index');然后在相应的view中的index文件中: 1 beginCache('cache_div')){?> 2 3 这里待会会被缓存 4 5 endCache();} 7 ?> 8...
阅读全文
摘要:1、缓存文件依赖1 $cache = \YII::$app->cache;2 $dependency = new \yii\caching\FileDependency(['fileName'=>'hw.txt']);3 $cache->add('file_key'...
阅读全文
摘要:先看数据表中的关系是怎样的:customer表中的关系如下:order中的表为:先在customer中获得order的数据,并与之关联,在helloController.php中,代码如下 1 where(['name'=>'zhangsan'])->one();11 // $orde...
阅读全文
摘要:在views中建立一个common.php文件,然后把views中的index.php和about.php公共代码放进去 1 2 3 4 5 Document 6 7 8 9 10 注意:这里的$content没有在任何一个地方赋值index.php中的内容为:...
阅读全文
摘要:如果在Controller中出现script代码类似$hello_str='Hello God';那么我不希望在传给view的时候出现弹框,那么就在view文件中使用use yii\helpers\Html;并且输出时使用Html::encode还有一种方法就是过滤调script代码:use yii...
阅读全文
摘要:0、首次安装请看 这里下面的为非首次安装,不需要token的步骤1、下载composer官网下载:https://getcomposer.org/download/2、开启PHP的openssl支持修改配置文件php.ini去掉extension=php_openssl.dll前面的注释3、安装Co...
阅读全文