Yii Framework Forum: TII framework and serialize() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

TII framework and serialize() Rate Topic: -----

#1 User is offline   webscriptz.be 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 24-August 09
  • Location:OLW WAVER, Belgium

Posted 25 January 2010 - 01:23 PM

Hello,

I have a table:

CREATE TABLE IF NOT EXISTS `legal` (
  `legalId` int(64) NOT NULL AUTO_INCREMENT,
  `legalName` varchar(512) NOT NULL,
  `legalCollection` text NOT NULL,
  PRIMARY KEY (`legalId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


and as you will probably have guessed, legalCollection should contain a serialized array. Now my question is how can i retrieve it using Yii in the most simplest form?

I can't use CActiveDataProvider because i don't think it converts my serialized array to an actual php array or does it?

Thanks,

Tim
0

#2 User is offline   devonc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-May 10

Posted 26 June 2010 - 11:49 PM

Why can't you use PHP implode() & explode() functions?
0

#3 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 27 June 2010 - 04:45 AM

You can override afterFind method in the active record class:

class Legal extends CActiveRecord
{

   public function afterFind()
   {

      $this->legalCollection = !empty($this->legalCollection) ? unserialize($legalCollection) : array();

      parent::afterFind();

   }

}

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users