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

codeigniter, codeigniter-datamapper, php

Solution

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.

Problem

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

Original source