Issue
Suppose $model hase some items (one to many relationship), So in Yii $model->items returns an array of item models.
How can I get an array of IDs of related items. This means each element of returned array is an integer.
Solution
You should simply write your own function for this, e.g.
public function getItemsIDs()
{
$ids = array();
foreach($this->items as $item)
$ids[] = $item->id;
return $ids;
}
After you just have to call $model->itemsIDs.
EDIT : as darkheir said in its comment, you should consider using DAO.
Answered By - soju
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.