CodeIgniter報錯: You must use the "set" method to update an entry


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

 

解答:

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.

 

比如在用rest工具測試的時候,post請求體沒有內容,或者沒有設置,會導致提示這個信息


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM