zoukankan      html  css  js  c++  java
  • mydetails-yii1

    1.yii验证码多余的get a new code ,即使在main.php中配置了中文也是出现获取新图片,影响效果
    需要把
    <?php $this->widget('CCaptcha'); ?>

    改成
    <?php
    $this->widget('CCaptcha',array('showRefreshButton'=>false,'clickableImage'=>true,'imageOptions'=>array('alt'=>'点击换图','title'=>'点击换图','style'=>'cursor:pointer'))); ?>

    2.yii提示属性未被定义时,Model中添加了规则,还提示属性未定义,如属性 "Order.formula_id" 未被定义.需要清除缓存Yii::app()->cache->flush();

    3.Warning: Invalid argument supplied for foreach.遇到这个问题需要在foreach遍历之前判断要遍历的变量是否是一个数组,if(is_array($info)),否则会报错

    4.yii两表关联查询

    例如:表soods和表brand,要通过goods_category_id=brand_id 关联goods和brand表

    首先:在Goods.php模型文件中
        public function relations(){
            return array(
                    'brands'=>array(self::BELONGS_TO, 'Brand', 'goods_brand_id','select'=>'brand_id,brand_name'),
            );
        }

    然后: 在goods的控制器GoodsController.php中,

    $infos = $goods_model -> findAll(array(
                        'select'=>'goods_id,goods_name,goods_price,goods_category_id,goods_brand_id,goods_number',
                        'condition'=>'goods_brand_id=:brand_id',
                        'order'=>'goods_price desc',
                        'with'=>array('brands'),
                        'params'=>array(':brand_id'=>$brand_id)
                ));
            //    print_r($infos[0]['brands']['brand_name']);exit;

    最后:视图文件中,

    <td><?php echo $info['brands']['brand_name']?></td>

    6.yii下拉框的默认值

    在模板文件中,<td><?php echo $form -> dropDownList($goods_model, 'goods_brand_id',CHtml::listData(Brand::model()->findAll(),'brand_id','brand_name'),array('empty'=>'请选择品牌'));?></td>,这样在显示下拉框数据的时候,第一条就是请选择品牌

  • 相关阅读:
    Atitit 图像金字塔原理与概率 attilax的理解总结qb23
    Atiti  attilax主要成果与解决方案与案例rsm版 v4
    Atitit 常用比较复杂的图像滤镜 attilax大总结
    Atitit. Api 设计 原则 ---归一化
    Atitit 面向对象弊端与问题 坏处 缺点
    Atitit  记录方法调用参数上下文arguments
    Atitit 作用域的理解attilax总结
    Atitit usrQBM1603短信验证码规范
    atitit 短信验证码的源码实现  .docx
    Atitit 图片 验证码生成attilax总结
  • 原文地址:https://www.cnblogs.com/xlz307/p/3822309.html
Copyright © 2011-2022 走看看