Hi Guys,
I'm trying to assign an array to a model field. The idea is that I'm going to automatically json encode/decode this field in the beforeSave and afterFetch functions. However I haven't been able to get this far yet because assinging arrays to model fields seems to act weird.
This code demonstrates the problem:
$test = new Test();
$test->name = 'The Real Name';
$test->network = array('name' => 'eth0', 'data' => 'stuff');
var_dump($test->toArray());
exit;
Test is an empty class extending \Phalcon\Mvc\Model
Output is this:
array (size=3)
'id' => null
'name' => string 'eth0' (length=4)
'network' => null
So it seems that the content of the array is somehow assigned to the model itself?
Does anyone have any idea how to solve this?
Thanks.
PHP Version 5.5.36 MSVC11 (Visual C++ 2012)
Phalcon Version 2.1.0r Build Date Apr 8 2016 18:17:26