随笔分类 -  yii2

PHP yii2框架
摘要:render() : 渲染一个 视图名并使用一个 布局返回到渲染结果。 renderPartial() : 渲染一个 视图名并且不使用布局。 renderAjax() : 渲染一个 视图名并且不使用布局, 并注入所有注册的JS/CSS脚本和文件,通常使用在响应AJAX网页请求的情况下。 阅读全文
posted @ 2017-11-21 17:43 pengcx 阅读(688) 评论(0) 推荐(0)
摘要:/** * ---------------------------------------------- * 操作成功跳转的快捷方法 * @access protected * @param string $message 提示信息 * @param string $jumpUrl 页面跳转地址 * @param mixed $a... 阅读全文
posted @ 2017-11-21 14:59 pengcx 阅读(1130) 评论(0) 推荐(0)
摘要:2.1、绑定参数 2.2、执行非查询语句 2.3、执行事务 3、关联查询 阅读全文
posted @ 2017-11-15 21:17 pengcx 阅读(2439) 评论(0) 推荐(0)
摘要:来源:https://www.cnblogs.com/attitudeY/p/6279985.html BUG描述:$ is not defined 没有加载jquery成功 原因:Yii2.0将JS代码默认加载页面加载后 解决方案: 第一种方案:最简单方法是在 assets\AppAsset.ph 阅读全文
posted @ 2017-11-09 08:49 pengcx 阅读(389) 评论(0) 推荐(1)
摘要:http://bootboxjs.com/examples.html#bb-confirm-dialog 阅读全文
posted @ 2017-09-14 17:07 pengcx 阅读(112) 评论(0) 推荐(0)
摘要:AR的生命周期 http://www.yii-china.com/doc/guide/db_active_record.html 理解AR的生命周期对于你操作数据库非常重要。生命周期通常都会有些典型的事件存在。对于开发AR的behaviors来说非常有用。 当你实例化一个新的AR对象时,我们将获得如 阅读全文
posted @ 2017-05-31 13:14 pengcx 阅读(1453) 评论(0) 推荐(0)
摘要:控制器生命周期 http://www.yii-china.com/doc/guide/structure_controllers.html 处理一个请求时,应用主体 会根据请求路由创建一个控制器,控制器经过以下生命周期来完成请求: 如果操作ID没有指定,会使用yii\base\Controller: 阅读全文
posted @ 2017-05-31 11:28 pengcx 阅读(1065) 评论(0) 推荐(0)
摘要:1、yii2系统登录 const EVENT_BEFORE_LOGIN = 'beforeLogin'; //登录前 const EVENT_AFTER_LOGIN = 'afterLogin'; //登录后 const EVENT_BEFORE_LOGOUT = 'beforeLogout'; / 阅读全文
posted @ 2017-05-31 11:13 pengcx 阅读(379) 评论(0) 推荐(0)
摘要:不跳转代码:return $this->redirect('http://www.yiichina.com/'); 跳转代码:return $this->redirect('http://www.yiichina.com/')->send(); 或者: $this->redirect('http:/ 阅读全文
posted @ 2017-05-31 10:27 pengcx 阅读(3195) 评论(0) 推荐(1)
摘要:1、样式和脚本 1.1 Yii 提供两个方法用于生成包含内联样式和脚本代码的标签。 阅读全文
posted @ 2017-05-27 17:54 pengcx 阅读(781) 评论(0) 推荐(0)
摘要:$transaction = Yii::$app->db->beginTransaction(); try{ //删除$model中的数据 $res = $model->deleteAll($cond); if(!$res) throw new \Exception('操作失败!'); //删除$m 阅读全文
posted @ 2017-05-25 16:54 pengcx 阅读(576) 评论(0) 推荐(0)
摘要:1、http://tech.anruence.com/ 2、http://www.yiichina.com/doc/guide/2.0/input-multiple-models 阅读全文
posted @ 2017-05-19 13:11 pengcx 阅读(135) 评论(0) 推荐(0)
摘要:<?php $form = ActiveForm::begin([ 'options'=>['class' => 'form-horizontal row-border','enctype'=>"multipart/form-data"], 'fieldConfig'=>[ 'options'=>[ 阅读全文
posted @ 2017-05-18 15:58 pengcx 阅读(712) 评论(0) 推荐(0)
摘要:1、在 model 里面定义一下场景 类名必须是 scenarios() 2、下面我们设置 rules() ,调用场景我们用 on 关键字 3、model 里面我们就设置完毕了 现在开始调用吧。 Controller 里面 阅读全文
posted @ 2017-05-12 17:57 pengcx 阅读(834) 评论(0) 推荐(0)
摘要:http://www.yii-china.com/doc/yii2-windows.html?id=278 阅读全文
posted @ 2017-05-12 15:35 pengcx 阅读(185) 评论(0) 推荐(0)
摘要:1、在控制台中切换到yii2控制台入口文件的工作路径。如:C:\users\2016-01>D:www\blogdemo\yii 阅读全文
posted @ 2017-05-09 08:38 pengcx 阅读(683) 评论(0) 推荐(0)
摘要:use yii\caching\Cache;$cache = Yii::$app->cache;$cache['var1'] = $value1; // equivalent to: $cache->set('var1', $value1);$value2 = $cache['var2']; //  阅读全文
posted @ 2017-05-02 13:27 pengcx 阅读(112) 评论(0) 推荐(0)
摘要:1、下载模板 2、环境变量配置 a.右击我的电脑-属性-高级-环境变量 b.找到 Path 这一项,鼠标双击 Path 这一项,在最后加入你的 PHP 目录和类库所在的路径,包括前面的“;”(例如:;C:\php;) c.点击“新建”按钮并在“变量名”中输入“PHPRC”,在“变量值”中输入 php 阅读全文
posted @ 2017-04-27 09:09 pengcx 阅读(141) 评论(0) 推荐(0)
摘要:2、请求方法 3、请求URL request 组件提供了许多方式来检测当前请求的URL。 假设被请求的URL是 http://example.com/admin/index.php/product?id=100, 你可以像下面描述的那样获取URL的各个部分: yii\web\Request::url 阅读全文
posted @ 2017-04-20 16:27 pengcx 阅读(281) 评论(0) 推荐(0)