【发布时间】:2013-11-20 14:29:53
【问题描述】:
我在运行我的 Php codeigniter 项目时收到此错误消息:
遇到了 PHP 错误
严重性:警告
消息:mtree::insert_to_right() 缺少参数 1,调用 C:\AppServ\www\News\application\controllers\bcontroller.php 在第 20 行 并定义
文件名:models/mtree.php
行号:28
这是我的模型函数:
function insert_to_right($row, $direct_id) {
$left_parent = $this->get_right_parent($direct_id);
$row->members_direct_id = $left_parent;
$this->db->insert('table1', $row);
$sql = "INSERT INTO table2 (child, parent)
VALUES (" . $this->db->escape($row->members_id) . ", " . $this->db->escape($left_parent) . ")";
$this->db->query($sql);
}
function get_right_parent($id) {
return $id;
}
【问题讨论】:
-
你能把你的控制器的代码贴在它调用这个方法的地方吗?
-
我就叫它
function index { $this->mtree->insert_to_right();} -
您需要向
insert_to_right('data', 'parent');传递一些内容,以便插入它们。现在你几乎只是在没有任何参数的情况下调用函数,这就是错误的原因。 -
当我调用控制器
$this->mtree->insert_to_right('members_id','members_direct_id ');上的函数时,我传递了这个参数,但它仍然响应另一个错误Message: Attempt to assign property of non-object
标签: php codeigniter