我剛剛安裝了Kohana 3.2的新副本,構建了我的數據庫,編寫了我的第一個模型,並嘗試測試它。一切正常,除了模型的「保存」方法執行兩次 - 我最終在數據庫中有兩個新條目,而不是一個。只有在使用下面顯示的「查找」代碼時纔會出現此問題。Kohana模型已保存兩次
爲什麼模型的保存會執行兩次,一次是預期的,一次是因爲發現?
下面的代碼:
class Controller_Welcome extends Controller {
public function action_index()
{
$rating = ORM::factory('rating');
$rating->user_id = 1;
$rating->userlevel_id = 3;
$rating->category_id = 1;
$rating->page_id = 1;
$rating->rating = 4;
$rating->comments = 'This one is a real killer';
$rating->ratingstatus_id = 1;
$rating->save();
$found = ORM::factory('rating')
->where('id', '=', 1)
->find();
$this->response->body($found->comments); // Test to check for found data
}
} // End Welcome
提前感謝!
感謝您的回覆。我嘗試了您的更改,但不影響任何內容。根據Kohana文檔[鏈接](http://kohanaframework.org/3.2/guide/orm/using),這些只是同一功能的不同變體。 – 2012-07-26 18:14:26