php - Yii Scope not being passed into CListView -
i'm trying pass model scope clistview
here scope in comment model
public function scopes() { return array( 'lastestcomment'=>array( 'alias' => 't', 'select'=>array('t.*,t2.*'), 'join'=>'join `comments_posts` t2', 'condition'=>'t.id=t2.commentid', 'order'=>'t.createdate asc', 'limit'=>'5' ) ); }
in view have this
$dataprovider=new cactivedataprovider(comment::model()->lastestcomment()); $this->widget('zii.widgets.clistview', array( 'dataprovider'=>$dataprovider, 'itemview'=>'_view', //view file location ));
in view, call $data
can values in comments
model , not comments_post
table in scope join. ideas?
you dont have make complicated acheive want,
yii simple
in model
public function relations() { return array( 'posts' => array(self::has_many, "commentposts", array("commentid" => "id")), ); }
in view
can data in comment table
as
$data->column_name
and data in comment_post table
foreach($data->posts $postings){ $postings->column_name; }
Comments
Post a Comment