I am trying to implement pagination in search results using Yii. I have pagination working on my post pages, but for some reason I am having problems with its work in the search.
So far, I have the following SQL for retrieving search results:
SELECT SQL_CALC_FOUND_ROWS DISTINCT user.id FROM user, personal_info WHERE (personal_info.bio LIKE '%a%' ) AND personal_info.user_id = user.id AND user.role = 'F' LIMIT 0, 8;
What is passed to ActiveRecord as follows:
$results = $this->findAllBySql($sql);
Right after that I run this code:
$rows = $this->findBySql("SELECT FOUND_ROWS() as row_count;");
echo $rows->row_count;
Oddly enough, I get the following error when trying to execute the above code:
The property "Search.row_count" is undefined.
For some reason, Yii cannot extract the value of FOUND_ROWS from MySQL.
PHP- ( SQL), . , Yii FOUND_ROWS. MySQL, , - SQL, FOUND_ROWS - , Yii.
, ?
!