jijianqiao

jijianqiao

我爱PHP

  • 财富值45
  • 威望值10
  • 总积分145

个人信息

  • 问题不详细,无法回答,只能揣测:

    比如:内容和ID直接使用特殊的符号将其连接起来比如“-”或者“|”

    $data->I_content = "我的内容是大法师地方-12";

    $arr = explode("-", $data->I_content);

    $id  = $arr[1];   //$data->I_content中特殊符号"-"只能唯一,不能出现两个以上 

  • 不需要呀,你可以参考 blog下面的 contact 下面的方法。

    public function actions()
    {
        return array(
            // captcha action renders the CAPTCHA image displayed on the contact page
            'captcha'=>array(
                'class'=>'CCaptchaAction',
                'minLength'=>4,
                'maxLength'=>5,
                'backColor'=>0xFFFFFF,
            ),
            // page action renders "static" pages stored under 'protected/views/site/pages'
            // They can be accessed via: index.php?r=site/page&view=FileName
            'page'=>array(
                'class'=>'CViewAction',
            ),
        );
    }
    

    将此代码附加在protected/components/Controller.php

    • 如果你写的SQL语句比较简单,建议使用下面的方法:
    //得到行数目或者其他数目 count
    // get the number of rows satisfying the specified condition
    $n=Post::model()->count($condition,$params);
    // get the number of rows using the specified SQL statement
    $n=Post::model()->countBySql($sql,$params);
    // check if there is at least a row satisfying the specified condition
    $exists=Post::model()->exists($condition,$params);
    
    • 如果你写的SQL语句比较复杂,建议使用下面的方法:
    $sql = "SELECT ...... FROM .........LEFT JOIN  offer o ON o.`offer_id`=......";
    
    $total_sql = "SELECT COUNT(o.offer_id) num ".strstr($sql, 'FROM');
    
    $this->connection->createCommand($total_sql)->queryScalar();
    
  • 谢谢楼主分享

  • 下来学习一下

  • 谢谢,楼主分享,下来看看

  • 谢谢,楼主分享,下来学习一下

  • 谢谢楼主分享,我下载学习一下

  • 下载下来学习一下

助理 等级规则
145/200
资料完整度
40/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

4

Ta的访客

3