【发布时间】:2013-01-17 15:17:14
【问题描述】:
我想在 Doctrine 2.3 中保存数据,不幸的是,如果可能我需要很好的教程,我也会出错,因为我认为文档没有用。
我的最后一个话题:
Controller error in CodeIgniter and Doctrine tutorial
厄洛尔:
致命错误:在第 19 行调用 C:\wamp\www\nauka\application\controllers\hello.php 中未定义的方法 User::save()
带有保存选项的图片:
型号
ripa 我做了你想要的,但我得到了错误:
解析错误:解析错误,在第 8 行的 C:\wamp\www\nauka\application\controllers\hello.php 中需要 `T_FUNCTION'
<?php
// system/application/controllers/hello.php
$this->load->model("user");
class Hello extends CI_Controller {
$this->user->setTableDefinition();
function world() {
echo "Hello CodeIgniter!";
}
function user_test() {
$u = new User;
$u->username = 'johndoe';
$u->password = 'secret';
$u->first_name = 'John';
$u->last_name = 'Doe';
$u->save();
$u2 = new User;
$u2->username = 'phprocks';
$u2->password = 'mypass';
$u2->first_name = 'Codeigniter';
$u2->last_name = 'Doctrine';
$u2->save();
echo "added 2 users";
}
}
?>
【问题讨论】:
-
好像你没有在 User 处扩展 Doctrine,而且 User 没有保存等方法。
-
@qeremy 你能在帖子中展示示例吗?
-
其实我没用过Doctrine,但是心理上需要在User类扩展一个类(有save方法)或者在User中定义save方法。
标签: php codeigniter doctrine