05 2017 档案

摘要:AR的生命周期 http://www.yii-china.com/doc/guide/db_active_record.html 理解AR的生命周期对于你操作数据库非常重要。生命周期通常都会有些典型的事件存在。对于开发AR的behaviors来说非常有用。 当你实例化一个新的AR对象时,我们将获得如 阅读全文
posted @ 2017-05-31 13:14 pengcx 阅读(1444) 评论(0) 推荐(0)
摘要:控制器生命周期 http://www.yii-china.com/doc/guide/structure_controllers.html 处理一个请求时,应用主体 会根据请求路由创建一个控制器,控制器经过以下生命周期来完成请求: 如果操作ID没有指定,会使用yii\base\Controller: 阅读全文
posted @ 2017-05-31 11:28 pengcx 阅读(1057) 评论(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 阅读(372) 评论(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 阅读(3190) 评论(0) 推荐(1)
摘要:1、样式和脚本 1.1 Yii 提供两个方法用于生成包含内联样式和脚本代码的标签。 阅读全文
posted @ 2017-05-27 17:54 pengcx 阅读(771) 评论(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 阅读(569) 评论(0) 推荐(0)
摘要:// WHERE name = 'dogstar' AND age = 18 $user->where(array('name' => 'dogstar', 'age' => 18)) // WHERE name = 'dogstar' OR age = 18 $user->or('name', ' 阅读全文
posted @ 2017-05-22 08:49 pengcx 阅读(2861) 评论(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 阅读(132) 评论(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 阅读(706) 评论(0) 推荐(0)
摘要:https://github.com/FriendsOfPHP/Goutte 阅读全文
posted @ 2017-05-12 18:04 pengcx 阅读(125) 评论(0) 推荐(0)
摘要:1、在 model 里面定义一下场景 类名必须是 scenarios() 2、下面我们设置 rules() ,调用场景我们用 on 关键字 3、model 里面我们就设置完毕了 现在开始调用吧。 Controller 里面 阅读全文
posted @ 2017-05-12 17:57 pengcx 阅读(828) 评论(0) 推荐(0)
摘要:http://www.yii-china.com/doc/yii2-windows.html?id=278 阅读全文
posted @ 2017-05-12 15:35 pengcx 阅读(181) 评论(0) 推荐(0)
摘要:下面就是打开的命令窗口,如果我们要修改成UTF8编码,输入命令 CHCP 65001 下面就是打开的命令窗口,如果我们要修改成UTF8编码,输入命令 CHCP 65001 阅读全文
posted @ 2017-05-09 10:06 pengcx 阅读(270) 评论(0) 推荐(0)
摘要:1、在控制台中切换到yii2控制台入口文件的工作路径。如:C:\users\2016-01>D:www\blogdemo\yii 阅读全文
posted @ 2017-05-09 08:38 pengcx 阅读(678) 评论(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 阅读(108) 评论(0) 推荐(0)