I'm confused by the way Magento's ORM behaves when editing/saving an object; see the example below:
$model = Mage::getModel('vendor/model')
->setData(array(
'name' => 'Test,
'description' => 'Info',
))
->save();
I now have a new record in the table, however this is where i'm confused.
$model = Mage::getModel('vendor/model')->load(1);
$model->setName('Test'); // THIS IS THE SAME
$model->setDescription('Info'); // THIS IS THE SAME
var_dump($model->hasDataChanges()); // returns true! (i expect false)
var_dump(($model->getData() !== $model->getOrigData())) // returns false (expected)
Surely the latter is how Magento should behave? Unless i'm missing something.
setData
then save, but this would query the database unnecessarily which surely it's more efficient for php to condition whether changes exist. Either way, I was only curious since I used the latter example above anyway, understanding I suppose._origData
array_data
, though for the purpose of write logic_data
may contain extraneous members which are not persisted (i.e. no corresponding attribute or column).