English 中文(简体)
在行政网页上进行高级搜索并不可行。 更改模型研究标准
原标题:Yii Advanced search at admin page does not work. Changed model->search() criteria
  • 时间:2012-05-14 03:26:16
  •  标签:
  • php
  • yii

我编辑了我的模型和模型;研究功能只是把数据与同一商业信息数据库看齐,但现在高级搜索并不奏效。

这里是我模型和模型研究的代码。

  public function search() {
    // Warning: Please modify the following code to remove attributes that
    // should not be searched.

    $criteria = new CDbCriteria;

    $criteria->compare( LOVEAGENT_ID , $this->LOVEAGENT_ID);
    $criteria->compare( FIRST_NAME , $this->FIRST_NAME, true);
    $criteria->compare( LAST_NAME , $this->LAST_NAME, true);
    $criteria->compare( DOB , $this->DOB, true);
    $criteria->compare( PASSWORD , $this->PASSWORD, true);
    ............


    $criteria->condition =  BUSINESS_ID=:businessID ;
    $criteria->params = array( :businessID  => Yii::app()->user->businessId);

    return new CActiveDataProvider($this, array(
                 criteria  => $criteria,
            ;
}

我的行政管理人员:

   public function actionAdmin() {
        $model = new LoveAgentContactDetails( search );
        $model->unsetAttributes();  // clear any default values

        if (isset($_GET[ LoveAgentContactDetails ])) {
            $model->attributes = $_GET[ LoveAgentContactDetails ];
        }

        $this->render( admin , array(
             model  => $model,
        ;
    }

和电网观测环境:

$this->widget( zii.widgets.grid.CGridView , array(
 id  =>  love-agent-contact-details-grid ,
 dataProvider  => $model->search(),
 filter  => $model,
 columns  => array(

     FIRST_NAME ,
     LAST_NAME ,
     lastLoginTime ,
     created ,

    array(
         class  =>  CButtonColumn ,
    ),
),

;

问题回答

这里的问题

 $criteria->condition =  BUSINESS_ID=:businessID ;

你们再说一下以前准备的条件。 您可使用<代码>CDbCriteria:add Conditions,但最佳方式是:

   $criteria->compare( BUSINESS_ID ,Yii::app()->user->businessId);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签