随笔分类 -  Yii Framework

摘要:<?php return array( 'class'=>'CUrlManager', 'urlFormat'=>'path', 'urlSuffix'=>'.html', 'showScriptName'=>false, 'caseSensitive'=>false,//it makes route case-insensitive. 'rules'=>... 阅读全文
posted @ 2010-04-21 11:53 DavidHHuan 阅读(611) 评论(0) 推荐(0) 编辑
摘要:mysql:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--'db'=array('connectionString'='mysql:host=localhost;dbname=tsmp','username'='root','password'='1','charset'='utf8', 'tablePrefix'='tbl_',//'schemaCachingDuration'=3600,//如果在main.php里面设置了c 阅读全文
posted @ 2010-04-21 11:53 DavidHHuan 阅读(784) 评论(0) 推荐(0) 编辑
摘要:public function filters(){ return array( ’postOnly + edit, create’, array( ’application.filters.PerformanceFilter - edit, create’, ’unit’=>’second’, ... 阅读全文
posted @ 2010-04-21 11:52 DavidHHuan 阅读(429) 评论(0) 推荐(0) 编辑
摘要:创建[代码]调用[代码] 阅读全文
posted @ 2010-04-21 11:52 DavidHHuan 阅读(833) 评论(10) 推荐(1) 编辑
摘要:main.php文件'modules' => array( 'admin' => require(dirname(__FILE__).DIRECTORY_SEPARATOR.'backend.php') )backend.php文件<?phpreturn array( //'sizePerPage' => 10, 'defaultController'=>'user'... 阅读全文
posted @ 2010-04-21 11:52 DavidHHuan 阅读(810) 评论(0) 推荐(0) 编辑
摘要:class MyWidget extends CWidget{public function init(){// this method is called by CController::beginWidget()}public function run(){// this method is called by CController::endWidget()}}通常,widget的视图是是放... 阅读全文
posted @ 2010-04-21 11:51 DavidHHuan 阅读(584) 评论(0) 推荐(0) 编辑
摘要:$this->widget('CMaskedTextField',array('mask'=>'99/99/9999')); 阅读全文
posted @ 2010-04-21 11:51 DavidHHuan 阅读(472) 评论(0) 推荐(0) 编辑
摘要:Ajax请求页面块的时候,是不希望加载layout的,这时候怎么向页面块传递参数呢?可以使用renderPartial()来代替render() 阅读全文
posted @ 2010-04-21 11:51 DavidHHuan 阅读(645) 评论(0) 推荐(0) 编辑
摘要:system: Yii framework directoryapplication: application's base directorywebroot: the directory containing the entry script fileext: directory of extensions 阅读全文
posted @ 2010-04-21 11:50 DavidHHuan 阅读(334) 评论(0) 推荐(0) 编辑
摘要:以on开关定义方法,如要clicked事件,public function onClicked($event){$this->raiseEvent('onClicked', $event);}调用的时候$component->onClicked=$callback;如果$callback是一个全局对象里面的方法,要用以下array($object, 'methodName')方法应该定... 阅读全文
posted @ 2010-04-21 11:50 DavidHHuan 阅读(406) 评论(0) 推荐(0) 编辑
摘要:例如,要存储timestamp的值是用MySQL now()函数,这时候可以这样,$post = new Post;$post->createTime=new CdbExpression('NOW()');//$post->createTime='NOW()';will not work because 'NOW()' will be treated as a string$post-... 阅读全文
posted @ 2010-04-21 11:49 DavidHHuan 阅读(660) 评论(0) 推荐(0) 编辑
摘要:public function ValidatorName($attribute,$params) f ... G 阅读全文
posted @ 2010-04-21 11:49 DavidHHuan 阅读(277) 评论(0) 推荐(0) 编辑
摘要:覆盖tableName()方法 阅读全文
posted @ 2010-04-21 11:48 DavidHHuan 阅读(255) 评论(0) 推荐(0) 编辑
摘要:直接在views里面使用$this->method(),如controller里面:Class PostController extends Ccontroller{Puvlic function actionList(){....}Public function getTitle(){return 'test title';}}views的list.php<?php echo $th... 阅读全文
posted @ 2010-04-21 11:48 DavidHHuan 阅读(502) 评论(0) 推荐(0) 编辑
摘要:$post->delete();进行以上操作的之后,AR实体是没有发生改变的,但是数据库里面的记录已经发生改变了 阅读全文
posted @ 2010-04-21 11:48 DavidHHuan 阅读(305) 评论(0) 推荐(0) 编辑
摘要:用一个方法来代替使用CActiveRecord::scopes例如public function recently($limit=5){$this->getDbCriteria()->mergeWith(array(’order’=>’createTime DESC’,’limit’=>$limit,)... 阅读全文
posted @ 2010-04-21 11:47 DavidHHuan 阅读(366) 评论(0) 推荐(0) 编辑
摘要:在数据查询的时候,出现下面的是什么意思?$posts=Post::model()->published()->recently()->findAll();这个是叫做named scope,每个命名范围被声明为一个可以被用来初始化CDbCriteria阵列实例。如要下面的例子class Post extends CActiveRecord{......public function... 阅读全文
posted @ 2010-04-21 11:47 DavidHHuan 阅读(318) 评论(0) 推荐(0) 编辑
摘要:MANY_MANY不能使用的属性:onBELONGS_TO不能使用的属性:limit Offset 阅读全文
posted @ 2010-04-21 11:46 DavidHHuan 阅读(555) 评论(0) 推荐(0) 编辑
摘要:在components文件夹下面建立一个文件AutoTimestampBehavior.php,里面的内容为<?phpclass AutoTimestampBehavior extends CActiveRecordBehavior {/*** The field that stores the creation time*/public $createTime = 'creatTime';... 阅读全文
posted @ 2010-04-21 11:46 DavidHHuan 阅读(689) 评论(0) 推荐(0) 编辑
摘要:public function defaultScope(){return array(’condition’=>"language=’".Yii::app()->language."’",);}这个方法对于每个实例的CRUD都是影响的。 阅读全文
posted @ 2010-04-21 11:46 DavidHHuan 阅读(442) 评论(0) 推荐(0) 编辑