Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthormarvin.s
    • CommentTimeDec 9th 2007
     
    class BetTheme extends ActiveRecord
    {
    var $serialize = "my_group";
    }

    when i performence:
    $betTheme = new BetTheme();
    $betTheme->name = "xxxx";
    $betTheme->my_group = array('isAll'=>true,......);
    $betTheme->save();
    occured some errors below
    Notice: Array to string conversion in D:/xampp/htdocs/alivenotdead/lib/AkActiveRecord.php on line 4178
    Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in D:/xampp/htdocs/alivenotdead/vendor/adodb/drivers/adodb-mysql.inc.php on line 137
    give me some suggestions please, thank you
    • CommentAuthorKaste
    • CommentTimeDec 9th 2007
     

    You assume that var $serialize = "my_group"; will do anything useful, but AFAIK it doesn't.

    But I think this is an easy one:

    We could have a table with a metadata_array column. Then we declare

    function setMetadata($value)
    {
        $this->set('metadata_array',serialize($value));
    }
    
    function getMetadata()
    {
        return unserialize($this->get('metadata_array'));
    }
    

    in the model. We now have a transparent or virtual attribute.

    $metadata = array('keywords'=>array('some','tags','here'),'descriptor'=>'xml-stuff');
    $Model->setMetadata($metadata); // or:
    $Model->set('metadata',$metadata); // or:
    $Model->create(array(...,'metadata'=>$metadata));
    
Add your comments
    Username Password
  • Format comments as