摘要:2011-05-26 09:38Yii dropDownList 下拉菜单 联动菜单'USA',7=>'France',3=>'Japan'),array( 'ajax' => array( 'type'=>'POST', //request type 'url'=>Yii::app()->createUrl('project/dynamiccities'), 'update'=>'#city_id
阅读全文
摘要:Yii框架zii.widgets.grid自定义按钮,ajax触发事件并提示博客分类:PHP我们在用表格展示数据并管理的时候,可能会需要用到按钮来操作某一行数据,比如查看,修改,删除!Yii内置了3种按钮:查看,修改和删除,你可以自定义样式、事件。详细配置见类参考:CButtonColumn.如果需要自定义按钮绑定指定的事件该怎么办呢?幸运的是Yii提供了自定义按钮的办法.看代码:在视图文件里面:Php代码 $this->widget('zii.widgets.grid.CGridView',array( 'id'=>'xx-xx-grid&
阅读全文
摘要:publicfunction actionAdmin(){ $model =newEmployee('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Employee'])) { $model->attributes = $_GET['Employee']; // save search parameters to the session data Yii::app()->user->setState('
阅读全文
摘要:CUploadedFile实现多文件上传方法:view视图代码: for($i=0;$i<3;$i++){ //echo $form->fileField($model,'xiangguan_tupian[]').'<br/>';//这种方法不行 //echo CHtml::activeFileField($model,'xiangguan_tupian[]');//这种也不行 //echo CHtml::fileField('xiangguan_tupian[]','',array(
阅读全文
摘要:Yii中文件上传下载 (CHtml::activeFileField)博客分类:PHPYii页面 ------------------------------------------------- Html代码 <?php$form=$this->beginWidget('CActiveForm',array( 'id'=>'add-form', 'enableClientValidation'=>true, 'clientOptions'=>array('validateOn
阅读全文
摘要:以Blog示例: 重点看注释User类中的relations方法如下 [php] view plaincopyprint? <span style="font-size:18px;background-color: rgb(255, 255, 255);"> public function relations() { return array( 'posts' => array(self::HAS_MANY, 'Post', 'author_id', 'order'=>'post
阅读全文
摘要:filters()方法定义在CController里,用Gii生成Controller时里面就有filters方法,代码如下:Java代码 publicfunctionfilters() { //returnthefilterconfigurationforthiscontroller,e.g.: returnarray( 'inlineFilterName', array( 'class'=>'path.to.FilterClass', 'propertyName'=>'propertyValue',
阅读全文
摘要:YII 存放登录信息的类如果在用户登录后想额外调用除 user,id之外的数据库变量,可以这样设置:在登陆验证时候增加额外项:Yii::app()->user->last_login_time在UserIdentity.php中Java代码 classUserIdentityextendsCUserIdentity { $this->setState('last_login_time',$user->last_login_time); }class UserIdentity extends CUserIdentity{ $this->setStat
阅读全文
摘要:Data pickerthe idea is the same as Date Picker but the different is that its generating data from database rather than date.to get this Data Picker working in the form you'll need CJuiDialog and CGridView.maybe the picture below will helps you to understand the idea a little bit. First of all yo
阅读全文
摘要:PHP5之_set和_get函数 接触PHP5也有一段时间了,尽管PHP5出了很长时间了,但大家对PHP5还是不甚感冒。在我的BLOG里讲一天PHP5的东西,希望能够对推动PHP5有所贡献。 先来看一个例子:class UserInfo{ var $UserName = ’’; var $PassWord = ’’; var $Birthday = ’’; }这个例子我想很多人在PHP4种也有用到,接下来给对象属性进行付值:$oUserInfo = new UserInfo; $oUserInfo->UserName = '木目'; $oUserInfo->Pass
阅读全文
摘要:Using filters with CGridView and CArrayDataProvider Follow @yiiframeworkreport it10023 followersModelControllerViewUsing filters on CGridView with CActiveDataProvider is easy, but with CArrayDataProvider it is a bit tricky.To use the filters you have to create a separate model class. I used some cod
阅读全文
摘要:DocumentationTake the TourTutorialsClass ReferenceWikiScreencastsResourcesDisplay an AJAX tree from your DB using CTreeView Follow @yiiframeworkreport it20020 followersThe databaseThe viewThe controllerIf AJAX failsFinal noteThe database ¶This example uses a MySQL DB with a table named tree wit
阅读全文
摘要:由数据库控制的CMenu菜单张迪 发表于2012年01月04日 | 查看4330次 | 评论(1) | 关注(1)顶(1) | 踩(0)这是一个简单的基于数据库的菜单系统,它使用 CMenu 渲染.数据库结构CREATE TABLE IF NOT EXISTS `menu` ( `menu_id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `date_added` datetime NOT NULL, `last_updated` datetime NOT NULL, `status` enum('a.
阅读全文
摘要:Yii AR很好很强大,但刚开始不知道怎么使用 如果英文不错,可以直接看原文地址http://www.yiiframework.com/doc/guide/1.1/en/database.ar下面是我对AR的一些理解对于一个Model Post 有如下的4中查询方法,返回对象或者对象数组。//findthefirstrowsatisfyingthespecifiedcondition$post=Post::model()->find($condition,$params);//findtherowwiththespecifiedprimarykey$post=Post::model()-
阅读全文
摘要:Yii的rules验证(表单字段验证)yii 验证rulesit分类:Yiiyii的rules验证cValidator主要属 性attributes,builtInValidators,enableClientValidation,message,on,safe,skipOnError经常用到的属性有attributes,builtInvalidators,message,on这四个下面是对应的验证类required:CRequiredValidatorfilter:CFilterValidatormatch:CRegularExpressionValidatoremail:CEmailVal
阅读全文
摘要:Yii实现Password Repeat Validate Rule发表回复在使用Yii时遇到这样的需求:在一个注册的页面输入两次密码,并验证两次输入是否一致。可是password的repeat的字段在数据库并不存在。问题来了,如何创建一个password_repeat的属性,进行密码验证。最偷懒的方法就是利用yii自带的验证器。在这里记录下实现的方法。假设项目结构如下protected/models/User.phpproteced/controllers/SiteController.phpprotected/views/site/forgot.php首先在User.php添加一个publ
阅读全文
摘要:http://www.yiiframework.com/extension/tlbexcelviewhttp://hi.baidu.com/95857548/item/0130511b07297c532b3e2209
阅读全文
摘要:今天本来是想研究一下AR模式的, 可是一不小心, 有陷入了master-slave的实现细节当中.研究之后我决定自己写一个master和slave链接的实现.当然首先让我们一起来看看我们常用的数据库查询需要的语句.$connection=Yii::app()->db;$command=$connection->createCommand($sql);$rowCount=$command->execute();标注为红色的地方引起了我的注意,于是有了以下几个想法:1) 这个db 明显是Yii 初始化的实例CwebApplication的一个成员变量, 但是在它及它的所有的父类中
阅读全文
摘要:相关的数据库代码[php] view plaincopyprint?#--------------------------------------------------------#Host:10.0.2.2#Serverversion:5.1.58-1ubuntu1#ServerOS:debian-linux-gnu#HeidiSQLversion:6.0.0.3603#Date/time:2011-11-3019:33:04#--------------------------------------------------------/*!40101SET@OLD_CHARACTER_
阅读全文
摘要:前段时间为SNS产品做了架构设计,在程序框架方面做了不少相关的压力测试,最终选定了YiiFramework,至于为什么没选用公司内部的PHP框架,其实理由很充分,公司的框架虽然是“前辈”们辛苦的积累,但毕竟不够成熟,没有大型项目的历练,犹如一个涉世未深的年轻小伙。Yii作为一个颇有名气开源产品,必定有很多人在使用,意味着有一批人在维护,而且在这之前,我也使用Yii开发过大型项目,Yii的设计模式和它的易扩展特性足以堪当重任。SNS同一般的社交产品不同的就是它最终要承受大并发和大数据量的考验,架构设计时就要考虑这些问题, web分布式、负载均衡、分布式文件存储、MySQL分布式或读写分离、NoS
阅读全文