gridview - yii dataprovider returns error 500 -


i tried defining dataprovider cgridview in yii getting

error 500: trying property of non-object

the following model , view/admin.php code snippets

model.php:

public function search2() {     $sql='select family_tree.tree_creator_id, c.user_fullname,      family_tree.tree_user1_id, a.user_fullname,     family_tree.tree_user2_id,b.user_fullname,     family_tree.tree_type, family_tree.tree_type_name     family_tree     join user on a.user_id=family_tree.tree_user1_id     join user b on b.user_id=family_tree.tree_user2_id     join user c on c.user_id=family_tree.tree_creator_id     ';      if($this->tree_creator_id!=null)     {         $sql.="where family_tree.tree_creator_id='$this->tree_creator_id'";     }      $a= yii::app()->db->createcommand($sql)     ->queryall();      return new carraydataprovider($a, array(         'id'=>'family-tree',         'keyfield'=>'tree_id')); } 

admin.php:

    <?php echo chtml::link('advanced search','#',array('class'=>'search-button')); ?> <div class="search-form" style="display:none">      <?php $this->renderpartial('_search',array(     'model'=>$model,     )); ?> </div><!-- search-form -->      <?php $this->widget('zii.widgets.grid.cgridview', array(     'id'=>'family-tree-grid',     'dataprovider'=>$model->search2(),      'columns'=>array(         'tree_id',         'tree_creator_id',         'tree_user1_id',         'tree_user2_id',         'tree_type',         'tree_type_name',          /*'tree_grey_flag',*/          array(             'class'=>'cbuttoncolumn',         ),     ), )); ?> 

any appreciated, thanks!

in select don't see

 'tree_id',  

and useful notation avoiding fields ambiguity

 tablename.columnname uniquefieldname  

and in gridview refer uniquefieldname

i hope useful


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -