Yii Framework Forum: CDbCriteria join problem with users table - Yii Framework Forum

Jump to content

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

CDbCriteria join problem with users table Rate Topic: -----

#1 User is offline   Nokia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 16-August 10

Posted 16 August 2010 - 12:11 PM

Hello,

i have a problem with CDBCriteria, it seems it can't get users table and name column.

The code:

Quote

$criteria = new CDbCriteria();
$criteria->join = "LEFT JOIN users ON users.id = userID";
$criteria->join .= " LEFT JOIN xxx ON xxx.id = type ";
$criteria->select = "t.*, xxx.title as type, users.name";


$models = xxx::model()->findAll($criteria);

$this->render('index', array(
'messages' => $models,
'pages' => $pages,
'xxx' => $this->xxx()
));



In view:

Quote

<div class="info_type"><div class="<?=$message["type"];?>"><?php echo $message["type"]; ?></div></div>
<div class="name"><?php echo $message["name"]; ?></div>


Error:

Quote

Description

Property "xxx.name" is not defined.


Any ideas?
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,600
  • Joined: 17-January 09
  • Location:Russia

Posted 17 August 2010 - 12:57 PM

Do you have name property in your xxx model?
0

#3 User is offline   Tushar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 30-July 13

Posted 01 August 2013 - 04:14 AM

yes i have a same error.
0

#4 User is offline   Mohammad Fareed 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 08-March 14
  • Location:Hyderabad

Posted 06 May 2014 - 05:42 AM

View Postsamdark, on 17 August 2010 - 12:57 PM, said:

Do you have name property in your xxx model?



Steps to add fields in the serch should have the following
1. public variable
2. add the field name in rules method in safe array
3. write you condition for fetch the result

Example :
$public $var;
public function rules()
{
array('var', 'safe', 'on'=>'search')
}
if 1, 2 are fail this error will be raised.
"variable var not defined".
-
With best Regards.
Mohammad Fareed.
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