Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'carraydataprovider'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello, I'm working in Yii framework. In my index action I created the dataprovider in the following way $connection=Yii::app()->db; $user_id = Yii::app()->user->id; $sql = 'SELECT * FROM post LEFT JOIN comment ON post.id = comment.post_id AND comment.user_id =:user_id LIMIT 0 , 30 '; $command=$connection->createCommand($sql); $command->bindParam(':user_id', $user_id,PDO::PARAM_STR); $rawData = $command->execute(); $dataProvider=new CArrayDataProvider($rawData, array( 'id'=>'user', 'sort'=>array( 'defaultOrder' => 'post.created', ), 'pagination'=>array( 'pageSize'=>10, ), )); then I render the index view $this->render('index',array( 'dataProvider'=>$dataProvider, 'category_id'=>$category_id, )); Index view is doing <?php $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'_view', )); ?> which cause the error Invalid argument supplied for foreach() C:\wamp\www\yii\framework\web\CArrayDataProvider.php(140) * @param array $directions the sorting directions (field name => whether it is descending sort) */ 136 foreach($directions as $name=>$descending) 137 { 138 $column=array(); 139 $fields_array=preg_split('/\.+/',$name,-1,PREG_SPLIT_NO_EMPTY); 140 foreach($this->rawData as $index=>$data) 141 $column[$index]=$this->getSortingFieldValue($data, $fields_array); 142 $args[]=&$column; 143 $dummy[]=&$column; 144 unset($column); 145 $direction=$descending ? SORT_DESC : SORT_ASC; 146 $args[]=&$direction; 147 $dummy[]=&$direction; 148 unset($direction); 149 } When I use $rawData = $command->queryAll(); instead of $rawData = $command->execute(); I got the error Call to a member function getAttributeLabel() on a non-object in C:\wamp\www\contest\protected\views\contest\_view.php on line 8 where the code is <b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b> Can you help me? Thank you in advance
×
×
  • Create New...