Yii 1.1: arraydataprovider

CArrayDataProvider takes an array of AR models for being used in an zii Widget like CListView.
3 followers

CArrayDataProvider takes an array of AR models for being used in an zii Widget like CListView.

Resources

Documentation

Requirements

  • Yii 1.1 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

Yii::import('application.extensions.CArrayDataProvider');
$posts = User->posts;
$dataProvider=new CArrayDataProvider('Post', $posts);
// $dataProvider->getData() will return a list of Post objects belonging to User

Change Log

December 19, 2009

  • Initial release.

Total 8 comments

#120 report it
Orteko at 2010/09/07 01:42am
Deprecated?

An implementation of this with the same name is now included in the core as of 1.1.4

Pretty easy changeover:

Whereas with this extension I used the following:

$contactsDP = new CArrayDataProvider('Contacts', $this->model->contacts);

This can now be simplified to

$contactsDP = new CArrayDataProvider($this->model->contacts);

#232 report it
persia at 2010/07/31 11:26pm
Sorting handling

Nice extension, but there's an update for this extension to sort by column: ex sort by posts or by categories.

Thanks

#704 report it
aztech at 2010/03/15 09:38am
Change fetchKeys

if you don't have key equal to 0, you fetchKeys will not work. Please change it into following

protected function fetchKeys()
    {
        foreach( current($this->dataArray) as $key => $value ) 
            $keys[] = $key;
        return $keys;
    }
#731 report it
Orteko at 2010/03/09 11:54pm
Great

Cheers, exactly what I was after :)

#744 report it
Rosimildo at 2010/03/06 04:41pm
Added Pagination handling.

I have modified this to handle pagination correctly.

protected function fetchData() { if( ( $pagination=$this->getPagination())!==false) {
$pagination->setItemCount($this->getTotalItemCount());
$offset = $pagination->getOffset(); $limit = $pagination->getLimit(); return array_slice( $this->dataArray, $offset, $limit ); } return $this->dataArray; }

#1052 report it
ekerazha at 2009/12/24 11:03am
Mmm

I use WinRAR and it couldn't extract bz2 :)

#1059 report it
thyseus at 2009/12/21 08:59am
Just added a .zip version

Just added a .zip version

but afaik winzip as winrar can extract .bz2 files under windows... :)

#1064 report it
ekerazha at 2009/12/20 10:25am
Not popular format

Not so popular format for the downloaded file (bz2) on not-*nix platforms, please use a more supported format (at least "gz" if not "zip").

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: thyseus
  • Category: Database
  • Votes: +6
  • Downloaded: 1,251 times
  • Created on: Dec 19, 2009
  • Last updated: never