Kohana ORM 模块不工作
我正在学习 Kohana,在尝试扩展模型以使用 ORM 时遇到以下错误。
Model_Message::create() 的声明应该与 Kohana_ORM::create() 的声明兼容
我已经在引导程序中启用了 orm 以及数据库。该错误在错误转储中突出显示以下行。
class Model_Message extends ORM {
这是我正在使用的模型代码,但失败了...
<?php defined('SYSPATH') or die('No direct script access');
/**
* Message modal
* Handles CRUD for user messages
*/
class Model_Message extends ORM {
/**
* Adds a new message for a user
*
* @param int user_id
* @param string user's message
* @return self
*/
public function create($user_id, $content)
{
$this->clear();
$this->user_id = $user_id;
$this->content = $content;
$this->date_published = time();
return $this->save();
}
}
我一直在浏览 api 文档,一切都表明这种从模型实现 orm 的方法是正确的方法所以。任何指点都会很棒。
I'm learning Kohana at the mo and encountering the following error when trying to extend a model to use ORM.
Declaration of Model_Message::create() should be compatible with that of Kohana_ORM::create()
I've enabled the orm in my bootstrap along with the database. The error highlights the following line on the error dump.
class Model_Message extends ORM {
And here is the model code I'm using and failing with...
<?php defined('SYSPATH') or die('No direct script access');
/**
* Message modal
* Handles CRUD for user messages
*/
class Model_Message extends ORM {
/**
* Adds a new message for a user
*
* @param int user_id
* @param string user's message
* @return self
*/
public function create($user_id, $content)
{
$this->clear();
$this->user_id = $user_id;
$this->content = $content;
$this->date_published = time();
return $this->save();
}
}
I've been going through the api documentation and everything is saying that this way of implementing the orm from the model is the correct way to do so. Any pointers would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要重命名您的方法(例如 create_message)或使其与 ORM 兼容(因为它有您尝试覆盖的它自己的 create 方法)。
You need to rename your method (create_message for example) or make it compatible with ORM (because it has the it's own create method which you try to override).