after issue deletion, it behaves weird.

I’ll add my million too Matt: thanks!!

Any idea why the search appears to keep working, even when I completely remove those 2 lines and don’t replace them?

ummm… those two lines were the wrong signature for the method so failed, but as they were added the search should function, but without the filter benefits…

I think ;)

I don’t understand scribbly. Can you say that again another way?

Not actual SQL statement. ‘params’ will bind to the SQL statement.




$criteria->condition='project_id=:projectID';

$criteria->params=array(':projectID'=>$this->project_id);



The params property will transform :projectId into the $this->project_id

The resulting SQL will be SELECT … FROM tbl_project WHERE project_id=123

Matt

scribbly is correct. By specifying $criteria->condition at the top, you’ll LIMIT the results to only issues for that project.




public function search()

        {

                        // Warning: Please modify the following code to remove attributes that

                        // should not be searched.


                        $criteria=new CDbCriteria;

                        

                        $criteria->condition='project_id=:projectID';

                        $criteria->params=array(':projectID'=>$this->project_id);


                        $criteria->compare('id',$this->id);

                        $criteria->compare('name',$this->name,true);

                        $criteria->compare('description',$this->description,true);

                        $criteria->compare('type_id',$this->type_id);

                        $criteria->compare('status_id',$this->status_id);

                        $criteria->compare('owner_id',$this->owner_id);

                        $criteria->compare('requester_id',$this->requester_id);

                        $criteria->compare('create_time',$this->create_time,true);

                        $criteria->compare('create_user_id',$this->create_user_id);

                        $criteria->compare('update_time',$this->update_time,true);

                        $criteria->compare('update_user_id',$this->update_user_id);


                        return new CActiveDataProvider(get_class($this), array(

                                        'criteria'=>$criteria,

                        ));

        }



Will generate: SELECT … from Issue WHERE project_id=123 AND name=‘dfdf’ AND …




public function search()

        {

                        // Warning: Please modify the following code to remove attributes that

                        // should not be searched.


                        $criteria=new CDbCriteria;

                        

                        // NOTICE THE CONDITION ISN'T PRESENT


                        $criteria->compare('id',$this->id);

                        $criteria->compare('name',$this->name,true);

                        $criteria->compare('description',$this->description,true);

                        $criteria->compare('type_id',$this->type_id);

                        $criteria->compare('status_id',$this->status_id);

                        $criteria->compare('owner_id',$this->owner_id);

                        $criteria->compare('requester_id',$this->requester_id);

                        $criteria->compare('create_time',$this->create_time,true);

                        $criteria->compare('create_user_id',$this->create_user_id);

                        $criteria->compare('update_time',$this->update_time,true);

                        $criteria->compare('update_user_id',$this->update_user_id);


                        return new CActiveDataProvider(get_class($this), array(

                                        'criteria'=>$criteria,

                        ));

        }



Will generate: Will generate: SELECT … from Issue WHERE name=‘dfdf’ AND …

Notice the difference in the WHERE statement. Both will apply the ‘compare’ values but the 1st will limit the result set to that project.

Matt

Thanks Matt (my heads buried in Chapter 8 at the moment…)

Thanks to both of you guys. I’m just getting to grips with PHP itself, nevermind frameworks. You’ve both been a great help here.

I figured out why my search function continues to work after the project specific criteria are removed. I have this line in my code (I didn’t add it, Gii must have created it) in addition to the other criteria->compare() methods:


$criteria->compare('project_id',$this->project_id);

With this also removed, the search does indeed return all issues, regardless of project context but with this in place, only issues from the pid=x project are returned in the dataprovider.