随笔分类 -  Yii Framework

摘要:What is CSRF, please see the details here.http://en.wikipedia.org/wiki/Cross-site_request_forgeryIn Yii, how to start the CSRF authorization? It is very easy to do that.Just add this to main.php[代码]And then, do something else to send a request to the server, you have to provide the YII_CSRF_TOKEN ( 阅读全文
posted @ 2011-01-19 15:41 DavidHHuan 阅读(1606) 评论(0) 推荐(0) 编辑
摘要:In Yii, we can define an action class and ask the controller to instantiate it. And we always create ourselves actions class in rootPath/protected/extensions, and the view file we called in the actions class always are located in rootPath/protected/views/ControllerNAME or rootPath/themes/ThemeNAME/C 阅读全文
posted @ 2011-01-10 17:11 DavidHHuan 阅读(281) 评论(0) 推荐(0) 编辑
摘要:Let say we have three table as:[代码]From their structure we can know that product table and category table are MANY_MANY relation, category_product is the middle table, then how can we get the product records when we have a category.id?Set the modelsProduct:代码Code highlighting produced by Actipro Cod 阅读全文
posted @ 2010-12-11 19:22 DavidHHuan 阅读(784) 评论(0) 推荐(0) 编辑
摘要:Here i will take stay.com for example, because this website i think is a very beatiful and flexiable website.For example, under her home page, the urls of the citys are as: http://www.stay.com/london,... 阅读全文
posted @ 2010-10-28 18:01 DavidHHuan 阅读(754) 评论(0) 推荐(0) 编辑
摘要:When reading the code of Yii blog example, we can find that, the code of site/login, as below:[代码]The LoginForm is located in protected/models, it extends from CFormModel, in the views/site/login.php,... 阅读全文
posted @ 2010-10-22 17:58 DavidHHuan 阅读(697) 评论(0) 推荐(0) 编辑
摘要:Here is a step by step to show how to run command in the server with yii framework.1. Create the web application.[代码]2. Edit myapp/protected/config/console.php:[代码]3. Create myapp/protected/commands/D... 阅读全文
posted @ 2010-10-20 14:32 DavidHHuan 阅读(1163) 评论(0) 推荐(0) 编辑
摘要:In fact that I am too poor to buy a server to run my website, but I want to run cron auto, so I use ajax to do it! :PIn the file of the layout, add the code as below:代码in the path /site/cron, you can ... 阅读全文
posted @ 2010-09-22 23:04 DavidHHuan 阅读(346) 评论(0) 推荐(0) 编辑
摘要:Maybe there is not a good introduction about how to embed css and images in a module in the forum (or cookbook) of Yii framework, but thanks to Qiang, who builds the great framework, that I found the ... 阅读全文
posted @ 2010-09-22 12:58 DavidHHuan 阅读(654) 评论(1) 推荐(1) 编辑
摘要:1. Create a file named "StringHelper.php", and locate it in protected/components , and insert the code as below:代码2. Demo[代码]Have fun with Yii! :) 阅读全文
posted @ 2010-08-23 23:26 DavidHHuan 阅读(358) 评论(0) 推荐(0) 编辑
摘要:There may be another good way to create and get the thumb image in Yii, here is my method to do it.1. You have to install this extension, "phpthumb", please search this extension in this website. 2. C... 阅读全文
posted @ 2010-08-23 22:30 DavidHHuan 阅读(450) 评论(0) 推荐(0) 编辑
摘要:By default, we can put the static pages in protected/views/site/pages.For example, I put the static "about.php" in protected/views/site/pages.The way of Yii to get the current name when to use in menu... 阅读全文
posted @ 2010-07-21 22:49 DavidHHuan 阅读(362) 评论(0) 推荐(0) 编辑
摘要:Below we list the core components that are pre-declared byCWebApplication.assetManager: CAssetManager -manages the publishing of private asset files.authManager: CAuthManager - manages role-based acce... 阅读全文
posted @ 2010-07-07 23:04 DavidHHuan 阅读(543) 评论(0) 推荐(0) 编辑
摘要:下面语句就可以获取当前控制器的名称了!Yii::app()->controller->id 阅读全文
posted @ 2010-04-21 11:56 DavidHHuan 阅读(744) 评论(0) 推荐(0) 编辑
摘要:<?php$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id'=>'myJuiDialog','options'=>array('title'=>'Edit the user profile','autoOpen'=>false,'buttons'=>array('ok'=>"js:f... 阅读全文
posted @ 2010-04-21 11:56 DavidHHuan 阅读(705) 评论(0) 推荐(0) 编辑
摘要:第一,比如说,我们要使用 Zend framework的东西。我们把zend framework解压到 prtected/vendors里面,现在的文件夹为 protected/vendors/Zend/Search/Lucene.php第二,在controller文件的头部,插入下面代码。Yii::import(’application.vendors.*’);requi... 阅读全文
posted @ 2010-04-21 11:55 DavidHHuan 阅读(926) 评论(0) 推荐(0) 编辑
摘要:要创建一个新的挂件(widget),我们主要是要继承两个方法:CWidget::init()和 CWidget::run(),CWidget::init 调用是发生在我们使用 $this->beginWidget 将挂件插入到一个view里面,CWidget::run 调用是发生在我们使用 $this->endWidget 这个方法的时候。 如果我们想捕捉和处理两者之间的方法核查办上显... 阅读全文
posted @ 2010-04-21 11:55 DavidHHuan 阅读(530) 评论(0) 推荐(0) 编辑
摘要:比如要使用mySQL中的md5函数,Test::model()->findAll(new CDbExpression("md5(name) =1")); 阅读全文
posted @ 2010-04-21 11:55 DavidHHuan 阅读(537) 评论(0) 推荐(0) 编辑
摘要:假设数据库的设置已经弄好了,里面的有一个User表建立User模型model User建立User的CRUD行为crud User创建 Modulemodule forum 阅读全文
posted @ 2010-04-21 11:54 DavidHHuan 阅读(543) 评论(0) 推荐(0) 编辑
摘要:把/media/MyDocuments/xampp/htdocs/myyii下面的index.php复制到/media/MyDocuments/xampp/htdocs/myyii/protected下面,然后将下面的代码$yii=dirname(__FILE__).'/framework/yii.php';$config=dirname(__FILE__).'/protected/config/... 阅读全文
posted @ 2010-04-21 11:54 DavidHHuan 阅读(433) 评论(0) 推荐(0) 编辑
摘要:创建应用,假设yii的核心文件夹framework是放在/media/MyDocuments/xampp/htdocs/myyiicd /media/MyDocuments/xampp/htdocs/myyiiphp framework/yiic.php webapp /media/MyDocuments/xampp/htdocs/myyii 阅读全文
posted @ 2010-04-21 11:54 DavidHHuan 阅读(422) 评论(0) 推荐(0) 编辑