i want to get relational query only one row from this table
album
===========
id
title
pic
===========
id
album_id
photo
create_time
my Relation
public function relations()
{
return array(
'albumPics' => array(self::HAS_MANY, 'Pic', 'album_id'),
'albumcount' => array(self::STAT, 'Pic', 'album_id'),
'albumfoto' => array(self::HAS_MANY, 'Pic','album_id', 'order'=>'create_time ASC', 'limit'=>'1'),
);
}
Problem Output here…
album.id
album.title
albumcount count from pic where album.id = pic.album_id
albumphoto get only one photo column from pic where album.id = pic.album_id order by create_time ASC limit 1
my index _view
<?php echo CHtml::encode($data->id); ?>
<?php echo CHtml::encode($data->title); ?>
<?php echo CHtml::encode($data->albumcount); ?>
<?php echo CHtml::encode($data->albumfoto); ?> --> error
Error
if using 'albumfoto' => array(self::HAS_ONE, 'Pic','album_id', 'order'=>'create_time ASC', 'limit'=>'1'),
error : Property "CHasOneRelation.limit" is not defined.
if using 'albumfoto' => array(self::HAS_MANY, 'Pic','album_id', 'order'=>'create_time ASC', 'limit'=>'1'),
error : htmlspecialchars() expects parameter 1 to be string, array given
Anyone can help… can i use relations for get photo column ?
thanks before