
YiiFreamework
宰相秋水
一个程序员
展开
-
yii 利用query 对数据库的操作
$connection = Yii::app()->db;$sql="SELECT * FROM `express_template` WHERE `ec_id`=$ec_id";$command = $connection->createCommand($sql); $result = $command->queryAll(); $imgAddress = YiiBase::getP原创 2012-02-22 11:48:40 · 6253 阅读 · 0 评论 -
yii模版中的写法
label($model,'remark'); ?>: textArea($model,'remark',array('class'=>'', 'rows'=>3,'cols'=>80)); ?> 都是调用model中的东西,的确很厉害原创 2012-04-26 15:21:37 · 981 阅读 · 0 评论 -
详解yii用户登录体系
二登录验证yii提供了CUserIdentity类,这个类一般用于验证用户名和密码的类.继承后我们需要重写其中的authenticate()方法来实现我们自己的验证方法.具体代码如下:class UserIdentity extends CUserIdentity { private $_id; public function authenticate() { $r转载 2012-04-19 10:42:20 · 10322 阅读 · 0 评论 -
yii调用文件的方式
getViewFile('_admin/_grid_view')?>这样在模版中,调用其他的模版文件。原创 2012-04-19 11:06:48 · 1480 阅读 · 0 评论 -
yii 用到的链接方式
在html中给文字加链接的方式为: href="createUrl('/shipping/Task/create')?>"原创 2012-04-19 09:58:34 · 666 阅读 · 0 评论 -
AR的一些常见的操作
一、查询数据集合1、$admin=Admin::model()->findAll($condition,$params);该方法是根据一个条件查询一个集合,如: findAll("username=:name",array(":name"=>$username)); 2、$admin=Admin::model()->findAllByPk($postIDs,$转载 2012-04-19 10:04:21 · 1135 阅读 · 0 评论 -
yii实现级联下拉菜单
在模版中<?php echo $form->dropDownList($model, 'src_type_id', OrderSrc::options(), array( 'id' => 'task-order-src-id', )); echo $form->dropDownList($model, 'src_shop_id', array(''=>'全部'), array原创 2012-04-19 11:40:03 · 3950 阅读 · 2 评论 -
YII assets使用
为什么用YII assets1.assets的作用是方便模块化,插件化的,一般来说出于安全原因不允许通过url访问protected下面的文件 ,但是我们又希望将module单独出来,所以需要使用发布,即将一个目录下的文件复制一份到assets下面方便通过url访问$assets = Yii::getPathOfAlias('ext').'/css';//$baseUrl = Y原创 2012-04-20 10:04:50 · 18796 阅读 · 0 评论 -
$route=$this->getAction()->id
$route=$this->getAction()->id原创 2012-04-20 17:30:27 · 1462 阅读 · 0 评论 -
yii模版中的判断方法
yii模版中的判断方法,isNewRecord):?>label($model,'order_sn'); ?>:order_sn?>不用解释了,看看就明白。原创 2012-04-26 15:19:21 · 5359 阅读 · 0 评论 -
yii 创建 验证码
转载地址: http://blog.sina.com.cn/s/blog_664c9f650100wkmp.html1,在SiteController action()下:return array( // captcha action renders the CAPTCHA image displayed on the contact pa转载 2012-03-14 09:45:02 · 1100 阅读 · 0 评论 -
yii 操作cookie
原文地址:http://blog.sina.com.cn/s/blog_664c9f650100yqkn.html设置cookie:$cookie = new CHttpCookie('mycookie','this is my cookie');$cookie->expire = time()+60*60*24*30; //有限期30天Yii::app()-转载 2012-03-14 09:40:29 · 17612 阅读 · 0 评论 -
yii 好地址
http://www.cnblogs.com/likwo/archive/2011/09/01/2162017.html原创 2012-02-22 21:13:37 · 700 阅读 · 0 评论 -
Yii-数据库操作-多表关联
1,首先多表关联是在models/xx.php的relations里配置的。而且是互配,但有区别。格式:'VarName'=>array('RelationType', 'ClassName', 'ForeignKey', ...additional options)需要弄清楚的几点:1,VarName指什么? 详见下面例2。2,RelationType。一共有4转载 2012-02-29 09:37:44 · 3354 阅读 · 0 评论 -
yii常用的两个url
当前页面url echo Yii::app()->request->url;跳转前一个页面url $this->redirect(Yii::app()->request->urlReferrer);原创 2012-02-29 15:48:55 · 894 阅读 · 0 评论 -
yii数据表关联操作
首先在model中进行表关联 public function relations() { return array_merge(parent::relations(), array( 'OrderAddonGiftinstock' => array (self::HAS_ONE, 'OrderAddonGiftinstock', 'order_id' ), )); }原创 2012-03-08 18:08:55 · 1776 阅读 · 2 评论 -
yii集成phpexcel
public function actionOutExcel(){ //echo Yii::app()->request->baseUrl; $danju = OrderInfo::model()->findByPk($_GET['id']); ob_end_clean(); ob_start(); /** PHPExcel */ //Y原创 2012-03-13 16:24:17 · 4890 阅读 · 1 评论 -
表单下拉选框及查询下拉选框
form表单 Views中: dropDownList($model,'cate_id',Category::model()->getCategoryList()); ?> Models中: public function getCategoryList() { $returnArr = $this->findAll(); return CHtml::listData(原创 2012-03-13 19:01:12 · 1169 阅读 · 0 评论 -
Yii CModel.rules() 方法 validate预定义完整列表
array( array('username', 'required'), array('username', 'length', 'min'=>3, 'max'=>12), array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'), array('password', '转载 2012-03-14 09:33:27 · 3146 阅读 · 0 评论 -
yii 操作session
在 Yii框架中使用session 的笔记:首先,在Yii框架中,你不需要像标准PHP代码那样使用session_start(),在Yii框架中,autoStart 属性缺省被设置为true,所以,虽然没有使用session_start(),你仍然可以使用$_SESSION全局变量,但最好使用Yii框架封装的Yii::app->session:设置session变量:转载 2012-03-14 09:38:37 · 15052 阅读 · 0 评论 -
利用类的属性来对时间区间的搜索
今天工作的时候遇到一个问题,一个模块的数据表只存了一个时间字段 add_time ,但是搜索是区间的。这个时候就可以用我的办法来解决了。这个问题比较常见,故而整理下来。 操作时间 start_time" id="start_time" value="" class="Wdate" onfocus="WdatePicke原创 2012-05-10 16:12:59 · 1087 阅读 · 0 评论