随笔分类 -  Yii Framework

摘要:PHPStorm8 license for Yincart project:https://github.com/yinheark/yincart2User Name: Yincart===== LICENSE BEGIN =====600435-24092014 00000CPsKQ18D66cz... 阅读全文
posted @ 2014-09-25 10:08 DavidHHuan 阅读(318) 评论(0) 推荐(0) 编辑
摘要:Yii Framework实现前后台frontend,backend分离的方法有几种,总结如下:1. 分开入口文件目录结构index.phpadmin.phpassets/...其它目录protected/ config/ main.php components/ controllers/ ...其它目录 admin/ config/ main.php components/ controllers/ ...其它目录网站正常的入口文件是index.php,我们加多一... 阅读全文
posted @ 2013-05-04 23:51 DavidHHuan 阅读(1611) 评论(4) 推荐(0) 编辑
摘要:1. 先到微信公众平台注册帐号http://mp.weixin.qq.com2. 下载demo微信公众平台提供了一个十分“朴素”的demo,说明如何调用消息接口的。代码真的很朴素,具体内容可到官网下载。3. 按照Yii的规则,做一个extension。这里命名为 weixin,目录结构如下:▾ extensions/ ▾ weixin/ Weixin.php*Weixin.php代码内容:<?php/** * WeixinCallback * * @package * @version $id$ * @copyright 1997-2005 The PHP Group * @... 阅读全文
posted @ 2013-04-02 21:26 DavidHHuan 阅读(5249) 评论(1) 推荐(0) 编辑
摘要:php版本davidhhuan@davidhhuan-ThinkPad-T410:~$ php -versionPHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli) (built: Sep 12 2012 18:59:41) Copyright (c) 1997-2012 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2012 Zend TechnologiesYii版本1.1.13Yii Framework使用spl_autoload_register实现类的自动加载,这个很大的方便我们不用每次 阅读全文
posted @ 2013-02-06 01:02 DavidHHuan 阅读(14136) 评论(0) 推荐(1) 编辑
摘要:I found a good plugin for vim, that isYii API manual for Vim, which you can checkthe api in vim!here is the website:https://github.com/vim-scripts/Yii-API-manual-for-VimBut that, why i write this article is that, when iCreatting custom version follows:git clone https://github.com/yiisoft/yii.git /me 阅读全文
posted @ 2013-01-12 03:08 DavidHHuan 阅读(17526) 评论(0) 推荐(0) 编辑
摘要:when i using$command = Yii::app()->db->createCommand(" SELECT * FROM vote v LEFT JOIN works w ON w.id = v.works_id LEFT JOIN activity a ON a.id = w.activ... 阅读全文
posted @ 2012-12-28 15:36 DavidHHuan 阅读(13242) 评论(0) 推荐(0) 编辑
摘要:When developing distributed applications with Yii, naturally, we will face that we have toshare the session in different machine. So here we will use memcache to do it.here is the example to store the session with memcache in Yii, in the main.php file: 'cache'=>array('class'=>& 阅读全文
posted @ 2012-11-22 02:09 DavidHHuan 阅读(10745) 评论(1) 推荐(0) 编辑
摘要:All the content of this article only happend in Yii Framework!As we know, with a form, we can both use post and get to send the data. But in Yii, when creating a form as below:<?phpechoCHtml::beginForm('user/index','get');?><?phpechoCHtml::label('User','user01 阅读全文
posted @ 2012-10-15 10:10 DavidHHuan 阅读(683) 评论(0) 推荐(0) 编辑
摘要:As we know, in Yii, we can set the error handler to display some useful message to the user.But, when i want to display different views in different modules, how to do it?Here is the way.In your module, here let say we have a admin module, there isAdminModule.php in it,then add the code as below:pub 阅读全文
posted @ 2012-10-03 16:55 DavidHHuan 阅读(695) 评论(0) 推荐(0) 编辑
摘要:From the code generated by the yiic, as we know, using these code can only get id and username from Yii::app()->user after logined:$identity=newUserIdentity($_POST['LoginForm']['username'],$_POST['LoginForm']['password']);Yii::app()->user->login($identity);bu 阅读全文
posted @ 2012-09-07 14:01 DavidHHuan 阅读(436) 评论(0) 推荐(0) 编辑
摘要:再谈Yii Framework中的事件event,我写过的关于Yii事件event的另一篇文章[Yii Framework] Yii中事件和行为的区别和应用 http://www.cnblogs.com/davidhhuan/archive/2012/01/19/2326123.html假设有类MyComponent,它是继承于CComponent,通过查看 CComponent 的 __set() 方法,publicfunction__set($name,$value){$setter='set'.$name;if(method_exists($this,$setter))r 阅读全文
posted @ 2012-07-23 16:28 DavidHHuan 阅读(728) 评论(0) 推荐(2) 编辑
摘要:This article comes fromhttp://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-siteOverall StructureTop-level DirectoriesApplication DirectoriesThe Common DirectoryApplication ConfigurationsPath AliasDeploymentLinksIn this article, we describe the directory structure used by 阅读全文
posted @ 2012-07-19 11:43 DavidHHuan 阅读(1050) 评论(0) 推荐(0) 编辑
摘要:这里假设我们要建立 中文/英文 切换的站点1. 设置全局默认的语言文件添加代码:protected/config/main.php'language'=>'zh_cn',2. 控制器根据用户选择动态切换语言一般来说,我们所有的控制器都是继承于 protected/components/Controller.php 这个类。因此,我们可以在这个类里面进行语言的定义来影响当前的请求。publicfunctioninit(){if(isset($_GET['lang'])&&$_GET['lang']!=" 阅读全文
posted @ 2012-06-15 15:47 DavidHHuan 阅读(33226) 评论(3) 推荐(1) 编辑
摘要:Official Website:http://www.chive-project.com/Here is its feature.Rich User interfaceChive is web-based and takes advantage of the capabilities of modern web browsers. See thescreenshotsfor impressions.Latest technologiesBased on top of the current version of the Yii framework, Chive takes advantage 阅读全文
posted @ 2012-02-25 22:01 DavidHHuan 阅读(404) 评论(0) 推荐(0) 编辑
摘要:个人觉得,在 Yii 里面,最难以明白的就是事件(Event)和行为(behavior)了。这不仅仅是因为它们的概念比较难明,关键是它们的应用场景比较难明,不知道什么时候应该使用事件和行为来开发。关于 Yii 的事件和行为的描述,可参考 http://www.yiiframework.com/doc/api/1.1/CComponent本文参考的文章:http://yiibook.yiiblogs.com/?p=584http://www.larryullman.com/2010/07/20/forcing-login-for-all-pages-in-yii/http://www.yiifr 阅读全文
posted @ 2012-01-19 09:35 DavidHHuan 阅读(3389) 评论(1) 推荐(1) 编辑
摘要:这是我见过对 Yii Framework 的 CComponent 写得比较好的文章,原文地址:http://www.yiiframework.com/forum/index.php?/topic/17072-ccomponent%E5%9F%BA%E7%A1%80%E7%B1%BB/CComponentCComponent类为YII框架的基于组件和事件驱动编程提供了基础,YII框架中的大部分类都将CComponent类作为基类。CComponent类为它的子类提供3个特性:1、成员变量扩展通过定义两个成员函数(getXXX/setXXX)来定义一个成员变量,比如:public functio 阅读全文
posted @ 2012-01-17 23:32 DavidHHuan 阅读(439) 评论(0) 推荐(0) 编辑
摘要:Here is an example of how to develop a widget (yes, widget is also an extension in Yii) in Yii.Let say you want to display something with widget in the page, of course you can place your widget in protected/componentswhen there are one or two classes inside. But when there is a lot of them,it is har 阅读全文
posted @ 2012-01-09 10:37 DavidHHuan 阅读(508) 评论(0) 推荐(0) 编辑
摘要:Here we will use CLinkPager for example.when using CLinkPager widget, we always follow this way: <?$this->widget(‘CLinkPager’,array('pages'=>$pages,'pageSize'=>15,))?>Here we set it to display 15 items per page. But if we have many action view page with CLinkPager, we 阅读全文
posted @ 2012-01-04 16:02 DavidHHuan 阅读(442) 评论(1) 推荐(0) 编辑
摘要:That is just a simple example here:<?php/****Export&importsql**@authordavidhhuan*/classDLDatabaseHelper{/***Exportthesqltoafile**@authordavidhhuan*@parambool$withData:Whethertoexporttheinsert-dataatthesametime*@parambool$dropTable:Addtodropthetableornot*@paramstring$saveName:thesavedfilename* 阅读全文
posted @ 2011-12-30 00:03 DavidHHuan 阅读(2770) 评论(0) 推荐(1) 编辑
摘要:When we using CGridView in Yii, we may want to a link as a column. So in common sense, we will use CLinkColumn to do that, as these code:<?php$this->widget('zii.widgets.grid.CGridView',array('dataProvider'=>$dataProvider,'columns'=>array(array('name'=>& 阅读全文
posted @ 2011-05-19 11:14 DavidHHuan 阅读(1407) 评论(0) 推荐(0) 编辑