Yii Framework Forum: Criteria Dosent Work In Php But Works In Phpmyadmin - Yii Framework Forum

Jump to content

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

Criteria Dosent Work In Php But Works In Phpmyadmin Criteria dosent work in php but works in phpMyAdmin Rate Topic: -----

#1 User is offline   Ervin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 27-May 12
  • Location:Romania

Posted 28 April 2013 - 11:43 AM

Hi everyone

I have a simple criteria with a single JOIN, when i execute it in php, i got results only from ProjectModel, but when i execute in phpMyAdmin i got result from project_rating table too.
In phpMyAdmin i run this query

SELECT `pr`.*,`p`.* FROM `project` `p` JOIN project_rating AS `pr` ON( `p`.P_Id = `pr`.Project_id ) WHERE 1=1 ORDER BY `p`.P_Add_date DESC



In Php i run this criteria, no results from project_rating table
$projectList                    = new ProjectModel();
 
$criteria                       = new CDbCriteria();
$criteria->alias                = "p";
$criteria->select               = "`pr`.*,`p`.*";
$criteria->join                 = "JOIN project_rating AS `pr` ON( `p`.P_Id  = `pr`.Project_id )";
$criteria->order                = "`p`.P_Add_date DESC";
 
$this->data["projectList"]     = $projectList->findAll( array(),$criteria );
 
$this->layout = "main";
$this->render('projectList');


I am sorry for my English
0

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 28 April 2013 - 05:35 PM

View PostErvin, on 28 April 2013 - 11:43 AM, said:


…
$this->data["projectList"]     = $projectList->findAll( array(),$criteria );
…



Please see http://www.yiiframew...#findAll-detail

you should write

$this->data["projectList"]     = $projectList->findAll( $criteria );

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