随笔分类 -  yii

1
yii
摘要:1 addSection();21 // Adding Text element to the Section having font styled by default...22 $section->addText(23 htmlspecialchars(24 ... 阅读全文
posted @ 2015-03-28 15:09 jami918 阅读(259) 评论(0) 推荐(0)
摘要:1 return $this->model()->getDbConnection()->createCommand()2 ->select("t.type,t.title,t.class_id,t.thumb,t.hours,t.real_pri... 阅读全文
posted @ 2014-12-10 15:41 jami918 阅读(202) 评论(0) 推荐(0)
摘要:1 protected function _init() 2 { 3 4 } 5 6 public function beforeAction($action) 7 { 8 //黑名单 9 $bla... 阅读全文
posted @ 2014-12-04 18:21 jami918 阅读(240) 评论(0) 推荐(0)
摘要:模块的定义就不写了,直接进入主题看目录和文件:application/modules/client/controllers/UserController.php 1 user->userid;13 $test = $this->user->test;14 $test1... 阅读全文
posted @ 2014-10-09 16:26 jami918 阅读(338) 评论(0) 推荐(0)
摘要:第一步,安装yii和wp:第二步,创建protected/components/ExceptionHandler.php文件statusCode == 404) { try { Yii::app()->runCo... 阅读全文
posted @ 2014-08-15 08:05 jami918 阅读(305) 评论(0) 推荐(0)
摘要:控制器public function actionCheckLogin(){if(!$this->createAction('verify_code')->validate($_POST['verfiy_code'], false)){ $error = '验证码不正确... 阅读全文
posted @ 2014-06-11 11:18 jami918 阅读(450) 评论(0) 推荐(0)
摘要:yii多表联合查询,第一种,用command,自己拼接sql语句执行查询第二种,用AR,model需继承下面的ar,执行queryall或queryrow方法 * public static function model($className=__CLASS__) * { *... 阅读全文
posted @ 2014-05-28 17:06 jami918 阅读(1522) 评论(0) 推荐(0)
摘要:今天需要做图片上传与生成缩略图的功能,把代码进行记录如下:html视图 ($pic_action_url = $this->createAbsoluteUrl('home/upload');) 1 2 3 4 5 6 7 8 9 10 11 1... 阅读全文
posted @ 2014-05-12 17:02 jami918 阅读(1752) 评论(1) 推荐(0)
摘要:问题:在yii中,一个controller会包含若干个action。有时为了重用或代码管理等目的,我们希望这些action可以单独定义成一个类,然后在controller中使用。那么在yii中要如何实现呢?假设我们有这样一个例子TestController.php,文件位于wwwroot/blog/... 阅读全文
posted @ 2014-05-06 17:35 jami918 阅读(907) 评论(0) 推荐(0)
摘要:yii index.phpini_set("display_errors", 1);iconv这个函数不能直接用 需要检测!!!function gb2312_utf8($str = ""){ if(function_exists("iconv")){ return iconv("gb2312", "utf-8//IGNORE", $str); }else if(function_exists("mb_convert_encoding")){ return mb_conver 阅读全文
posted @ 2014-01-26 14:17 jami918 阅读(181) 评论(0) 推荐(0)
摘要:1 application\components\controller.php2 3 protected function afterRender($view, &$output) 4 { 5 if(Yii::app()->params['compress_on']){ 6 Yii::import('ext.Compress', true); 7 $output = Compress::minify($output, array('xhtml' => true)); 8 } 9 }extension\Compress.php 阅读全文
posted @ 2014-01-07 17:46 jami918 阅读(341) 评论(0) 推荐(0)
摘要:过滤器官方页面:http://www.yiiframework.com/doc/guide/1.1/zh_cn/basics.controller过滤器是一段代码,可被配置在控制器动作执行之前或之后执行。例如, 访问控制过滤器将被执行以确保在执行请求的动作之前用户已通过身份验证;性能过滤器可用于测量控制器执行所用的时间。一个动作可以有多个过滤器。过滤器执行顺序为它们出现在过滤器列表中的顺序。过滤器可以阻止动作及后面其他过滤器的执行过滤器可以定义为一个控制器类的方法。方法名必须以filter开头。例如,现有的filterAccessControl方法定义了一个名为accessControl的过滤 阅读全文
posted @ 2013-12-24 11:02 jami918 阅读(1163) 评论(0) 推荐(0)
摘要:public void __construct(integer $status, string $message=NULL, integer $code=0)$statusintegerHTTP状态码,如403,404,500等等。$messagestring错误信息$codeinteger错误代码源码: framework/base/CHttpException.php publicfunction__construct($status,$message=null,$code=0){$this->statusCode=$status;parent::__construct($messa 阅读全文
posted @ 2013-12-24 10:07 jami918 阅读(1382) 评论(0) 推荐(0)
摘要:1,main.php 里面导入'import' => array( 'application.components.*' ),2,application/components/BaseComponent.php_url = $value; } public function getUrl() { return $this->_url ; } public function test() { return 'test'; }}4,application/components/Controller.phpclass Controller 阅读全文
posted @ 2013-12-20 14:44 jami918 阅读(693) 评论(0) 推荐(0)
摘要:让ar执行queryall和queryrow方法返回数组dbActiveGroup(); if(isset(self::$_dbConnections[$activeGroup])) { return self::$_dbConnections[$activeGroup]; } else { $dbConnection = ConnectionHelper::get($activeGroup); if( ! empty($dbConnection) && $dbConnection instanceof CDbConnection) { self::$_dbCo... 阅读全文
posted @ 2013-12-06 17:23 jami918 阅读(1110) 评论(0) 推荐(0)
摘要:main.php://替换所有模板//加载文件名为first的模板// 'theme'=>'theme1', 'components'=>array( //改变主题basepath 'themeManager'=>array( 'basePath' => __DIR__. '/../themes' ),//单个控制器: public function actionIndex(){ Yii::app()->setTheme('theme1'); 阅读全文
posted @ 2013-11-15 14:23 jami918 阅读(215) 评论(0) 推荐(0)
摘要:Yii里获取当前controller和action的id 在控制器里$name = $this->getId(); // controller$name = $action->id; // action在视图里$name = $this->id = Yii::app()->controller->id; // controller$name = $this->action->id = $this->getAction()->getId(); // action 阅读全文
posted @ 2013-07-29 11:02 jami918 阅读(890) 评论(0) 推荐(0)
摘要:1. 创建配置文件protected/config/main.php 1 <?php 2 3 // This is the main Web application configuration. Any writable 4 // CWebApplication properties can be configured here. 5 return array( 6 7 // preloading 'log' component 8 'preload'=>array('log'), 9 10 // application compon 阅读全文
posted @ 2013-05-21 20:55 jami918 阅读(520) 评论(0) 推荐(0)
摘要:Yii的Model ( 模型)创建及使用YII 实现了两种模型,表单模型(CFormModel类)和ActiveRecord模型(CAtiveRecord类),它们都继承自CModel类。 CFormModel代表的数据模型是从HTML表单收集的输入,封装了所有逻辑(如表单的验证和其它业务逻辑,应用到表单的域上)。它能将数据存储在内 存中,或者在一个ActiveRecord的帮助下,存入数据库里。一.基于CActiveRecord的ModelActiveRecord(AR)是一种设计模式,用面向对象的方式抽象的访问数据,Yii中,每一个AR对象的实例都可以是CActiveRecord类或者它的 阅读全文
posted @ 2013-05-15 16:14 jami918 阅读(418) 评论(0) 推荐(0)
摘要:框架无非就是mvc,只是调用的父类操作比较繁琐。登录:C:TestController.php/actionLogin方法 public function actionLogin() { $model=new TestLogin; if(isset($_POST['ajax']) && $_POST['ajax']==='login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if(isset($_POST['TestLogin& 阅读全文
posted @ 2013-05-03 22:27 jami918 阅读(320) 评论(0) 推荐(0)

1