When creating rows with Phactory, omitted optional columns are filled with null in the database. This is convenient because I don't have to provide every column in my definition of of a table (which is subject to change unexpectedly/often). However, when I create objects from Phactory Rows, I often want them to mirror what is in the database - not what is in the internal storage of a Phactory Row (which doesn't account for those null columns).
To get arround this I am doing:
$user = Phactory::create('user');
$user = Phactory::get('user', array('id' => $user->getId());
$user_object = new User($user->toArray());
This will allow us to instead use:
$user = Phactory::create('user');
$user_object = new User($user->fill()->toArray());
When creating rows with Phactory, omitted optional columns are filled with null in the database. This is convenient because I don't have to provide every column in my definition of of a table (which is subject to change unexpectedly/often). However, when I create objects from Phactory Rows, I often want them to mirror what is in the database - not what is in the internal storage of a Phactory Row (which doesn't account for those null columns).
To get arround this I am doing: $user = Phactory::create('user'); $user = Phactory::get('user', array('id' => $user->getId()); $user_object = new User($user->toArray());
This will allow us to instead use: $user = Phactory::create('user'); $user_object = new User($user->fill()->toArray());