Retrieving Record From Db

I’m attempting to execute a query with the following format:

$criteria = new CDbCriteria;

$condition_string  = ' origin=\''.$input['origin'].'\'';

$condition_string  .= ' AND destination=\''.$input['dest'] .'\'';

$criteria->condition = $condition_string;

$pricing = Pricing::model()->with('pricing_routes')->findAll($criteria);

The query should retrieve two records from the database. If I enable logging, copy and paste the query Yii is executing into my db tool. The query retrieves two records, as it should.

The problem I’m having is:


only yields one result. So obviously, when I’m trying to loop through the $pricing array, I’m not getting the appropriate results.

Any idea of what could be going on here? TIA.

How is $pricing translated into $pricing_records? And why, if you only need the count, don’t you use the COUNT() function of MySql?

My mistake. it should read:


And I just used count() function to show that there was only one result in the array.

I could have just said:

foreach($pricing as $temp){echo 'here';}

and have it only display "here" once.