随笔分类 - yii2.0
摘要:Yii2框架引用bootstrap中日期插件yii2-date-picker的方法。 使用composer安装 日期插件 php composer.phar require "2amigos/yii2-date-picker-widget" "*" 或 composer require 2amigo
阅读全文
摘要:yii2.0 访问控制器下的方法时出现 Object Not Found! 时 可以查看(apache) 入口文件index.php 的同级有没有 .htaccess 文件 没有.htaccess文件 要添加该文件 内容: 1 RewriteEngine on 2 RewriteCond %{REQ
阅读全文
摘要:1 2 3 4 id;?>"> 5 6 点击按钮显示模态框 7 8 9 id;?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 10 11 12 13 x 1...
阅读全文
摘要:<script type="text/javascript"> function getcitytext(){ citytext = ''; $(".citylist select").each(function(){ if($(this).val()>0){ citytext += $(this)
阅读全文
摘要:/** * 删除文件缓存 */public function actionDelfilecache(){ $cachePath = Yii::getAlias('@app/runtime/cache');//文件绝对路径 $fileArray = scandir($cachePath);//将文件夹
阅读全文
摘要:<a href="<?=Url::to(['default/logout']);?>" title="退出"><span class="glyphicon glyphicon-log-out"></span></a> class DefaultController extends Controlle
阅读全文
摘要:yii2.0 中的ActiveForm 复选框的使用 默认的复选框选项为纵向的<?= $form->field($model, 'line')->checkboxList(Picture::$lines);?> 将复选框的选项改为横向的<?= $form->field($model, 'line')
阅读全文
摘要:在视图中创建复选框,列出复选框内的内容其中$id 为 列出在复选框中的数组 //$ids:所有要显示的checkbox(Array)<?=$form->field($model, 'id')->checkboxList($ids);?> 要将复选框设置默认值//$yuanId:默认选中的(Array
阅读全文
摘要:yii2 curl的使用办法 get: 当访问https是可能会出现空白需要将ssl设置为false $curl->setOption(CURLOPT_SSL_VERIFYPEER, false); post: // POST URL form-urlencoded // post 请求 , 数据格
阅读全文
摘要:直接 model 删除 带有条件的删除 使用 Query 查询删除 使用预处理语句删除 方法一 方法二 在 Yii2 使用预处理语句删除多个用户。 查找并且删除 deleteAll() 删除多个 如果你不指定任何条件下,该方法将删除表中的所有行。例如删除用户表中状态条件是 active 和年龄大于2
阅读全文
摘要:在config/web.php 添加 $config = [ 'defaultRoute' => 'login/login', ];
阅读全文
摘要:yii2.0在浏览器中默认查看控制器下的方法是 http://ltbk.cn/index.php?r=login/login 要是在浏览器上输出 http://ltbk.cn/index.php/login/login就更加方便 下面解决方法: 1. 打开config目录下的web.php,在$co
阅读全文
摘要:yii\web\Request::cookieValidationKey must be configured with a secret key. 出现的错误表示没有设置 cookieValidationKey 解决方法: 打开 basic\config\web.php 设置代码如下
阅读全文
摘要:getErrors('province_id') || $model->getErrors('city_id') || $model->getErrors('district_id')):?>has-errorhas-success"> 配电室所在地区 '请选择省份'], Area::getArrayForInput(0)), ['cl...
阅读全文
摘要:第一种方式:采用model 1. 模型:Code.php <?phpnamespace app\models; use yii\base\Model;class Code extends Model{ public $code;//添加的验证码字段 public function rules() {
阅读全文
摘要:1 HTML: 2 3 4 "> 5 6 "> 7 查询 8 9 10 11 控制器的查询条件: 12 $data = Concentrator::find()->andWhere(['in', 'id', $cIds]); 13 if ($_GET['name']) ...
阅读全文
摘要:$this->redirect(['default/error']); Yii::$app->end();上边的代码出现 Calling unknown method: app\modules\mobile\controllers\CompanyController::redirect()错误时,查
阅读全文
摘要:登录 网站/distributor/default/index之后,保存当前的session,想要进入 网站/company/default/index 时通过权限设置,若session有company相关的记录就跳转到相关页面,若session中没有company相关的记录就跳转到登录的页面. y
阅读全文
摘要:<?php /** * 图片常用处理 * * 需要 yii/yii2-imagine 的支持 * php composer.phar require --prefer-dist yiisoft/yii2-imagine * * 文件上传参考文档编写文件上传类 * @link http://www.y
阅读全文