Yii Framework Forum: [SOLVED] Ch 6 Issue Search issue - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Ch 6 Issue Search issue Just finished chapter 6 and Issue search does not filter

#1 User is offline   scribbly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 27-June 11
  • Location:Blue Mountains :: Australia

Posted 07 July 2011 - 11:22 AM

I've just [finally] finished chapter 6 (and enjoying the ride)... but the search functionality has disappeared from my issues page.

Projects works, but issues keeps displaying all records regardless of the search criteria (ie id=1 I'd expect to return one record).

Any hints how I can track down the problem??

Thanks BTW to all the helpful posters here about the book: made it much more possible!!
0

#2 User is offline   scribbly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 27-June 11
  • Location:Blue Mountains :: Australia

Posted 08 July 2011 - 09:51 AM

I've now downloaded the code and there is no difference (apart from edits in future chapters), but the searh does not filter the records.

Would really like to understand how this has happened and how to fix??
0

#3 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 21 July 2011 - 11:48 PM

Please take a look at the Issue::search() method in the model class file Issue.php. Towards the end of that method, there may be a typo that results in all previously set criteria conditions being overwritten, rather than appended to. If you change this:

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


to

$criteria->addCondition('project_id=:projectID');


It should address your search issues you are experiencing.

0

#4 User is offline   scribbly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 27-June 11
  • Location:Blue Mountains :: Australia

Posted 22 July 2011 - 07:25 AM

Thanks Jeff. I actually hooked onto this thread which sorted out the problem.

I meant to mention in this thread too, but I got too excited and finished the book!! Loved it by the way, I'm now "re-doing it" for my own project (which is different).

View Postjefftulsa, on 21 July 2011 - 11:48 PM, said:

Please take a look at the Issue::search() method in the model class file Issue.php. Towards the end of that method, there may be a typo that results in all previously set criteria conditions being overwritten, rather than appended to. If you change this:

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


to

$criteria->addCondition('project_id=:projectID');


It should address your search issues you are experiencing.

0

#5 User is offline   seb7 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 03-April 12

Posted 03 April 2012 - 03:56 AM

i've made the change but now it fire an sql error
CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. The SQL statement executed was: SELECT COUNT(*) FROM `tbl_issue` `t` WHERE (project_id LIKE :ycp0) AND (project_id=:projectID)


i'm using Yii 1.1.10

So I found a solution before posting the prob, I guess it's good but not so sure,

Replaced (2 lines)
$criteria->addCondition('project_id=:projectID');
$criteria->params = array(':projectID' => $this->project_id);

to 1 line
$criteria->addColumnCondition( array( 'project_id' => $this->project_id) );


( ./yii-docs-1.1.8.r3324/api/CDbCriteria.html#addColumnCondition-detail )
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users