Achille Achille Thu Apr 18 21:53:44 -0400 2013

Subject: Problem with fields who does not exists in database

Hi everyone,

I'm actually facing an issue using AR. I'm trying to make a file uploader. The problem is that the $_FILES array contain the keys 'error' and 'tmp_name' and I've got an error when trying to create a new media in order to validate ( :

Undefined property: Media->tmp_name in /var/www/metrolistings/library/ActiveRecord/lib/Model.php on line 420 Undefined property: Media->error in /var/www/metrolistings/library/ActiveRecord/lib/Model.php on line 420

I need both of those key in my custom validation system. How can I tell to AR to consider variables even though there are not a part of the database fields?

Thanks a lot for your help

Alex J Thu Apr 18 22:02:31 -0400 2013

Try this approach:

$file_new_object = new Media();
$file_new_object->media = $_FILES['media'];

Achille Achille Thu Apr 18 22:27:15 -0400 2013

Thanks for your answer but it's still not working. I've got this error :

Undefined property: Media->media in /var/www/metrolistings/library/ActiveRecord/lib/Model.php on line 420


Alex J Thu Apr 18 23:04:46 -0400 2013

var_dump(that Media) Copy paste the contents..


Achille Achille Thu Apr 18 23:06:36 -0400 2013

Ok I finally make it worked using the assign_attribute method :

$file->assign_attribute('media', $_FILES['media']);

Thanks for the help

Alex J Thu Apr 18 23:07:17 -0400 2013

waow your fast!