tags:

views:

609

answers:

1

Hi,

I've got an array of values I want to update my model with.

Doctrine_Access provides a function setArray which is nearly exactly what I need - except it cares about values that don't have fields in the model. I want those to be ignored.

A little example. Say we have a User table with the field username.

$user = new User();
$user->setArray(array('username'=>'xyz'))->save();

That would work!

$user = new User();
$user->setArray(array('username'=>'xyz','anotherKey'=>'anotherValue'))->save();

That doesn't. I want Doctrine to just ignore anotherKey, if there is no related field. The intention is, that I don't want to filter my arrays before I update my model.

What is the cleanest and easiest way to get this done?

Thanks!

A: 

Doctrine_Record::fromArray() solves it. Unfortunately it doesn't return the object, so it's useless for method chaining...

janoliver