CodeIgniter DataMapper Error: You must use the "set" method to update an entry

jx12345 picture jx12345 · Apr 25, 2013 · Viewed 11.9k times · Source

I'm using codeigniter/datamapper to develop an inviocing application and I'm getting an error that i don't understand. If I do the following:

$i = new Invoice();    
$i->save();

Then i get the following error: A Database Error Occurred

You must use the "set" method to update an entry.

Filename: /Users/jim/Sites/example.com/libraries/Datamapper.php

Line Number: 1635

However I can run this all day without any problem:

$i = new Invoice();    
$i->notes ='x';
$i->save();

Just wondered why it behaves like this? Any help/comments much appreciated. Thanks

Answer

Ganesh Kanawade picture Ganesh Kanawade · Apr 27, 2013

For the datamapper you must assign the value to the object. If the object is empty then it is not going to save. So firstly set the value for the datamapper object.