Codeigniter,严重性:错误 --> 异常:函数参数太少,管理仪表板显示 HTTP 错误 500
Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500
我在日志文件中遇到错误
这个
ERROR - 2022-05-13 02:47:21 --> Severity: error --> Exception: Too few arguments to function Transactions_model::get_pending_dash(), 0 passed in /Applications/MAMP/htdocs/application/controllers/admin/Dashboard.php on line 47 and exactly 1 expected /Applications/MAMP/htdocs/application/models/Transactions_model.php 2134
这是第 47 行 dashboard.php 控制器下的确切代码:
$transactions = $this->transactions_model->get_pending_dash();
这是 transactions_model.php 型号下的确切代码:
// total transactions ////////////////////////////////////////////
function total_dash_transactions()
{
$s= $this->db->select("COUNT(*) as num")->get("transactions");
$r = $s->row();
if(isset($r->num)) return $r->num;
return 0;
return $result[0]->Transactions;
}
function get_pending_dash($user)
{
$where = "status = '1' AND type = '2'";
return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
}
因为在你的函数中 get_pending_dash 需要 $user
作为参数,但是根据你的代码你也没有使用它所以如果你没有使用参数就删除 $user
喜欢下面的代码。
function get_pending_dash()
{
$where = "status = '1' AND type = '2'";
return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
}
我在日志文件中遇到错误 这个
ERROR - 2022-05-13 02:47:21 --> Severity: error --> Exception: Too few arguments to function Transactions_model::get_pending_dash(), 0 passed in /Applications/MAMP/htdocs/application/controllers/admin/Dashboard.php on line 47 and exactly 1 expected /Applications/MAMP/htdocs/application/models/Transactions_model.php 2134
这是第 47 行 dashboard.php 控制器下的确切代码:
$transactions = $this->transactions_model->get_pending_dash();
这是 transactions_model.php 型号下的确切代码:
// total transactions ////////////////////////////////////////////
function total_dash_transactions()
{
$s= $this->db->select("COUNT(*) as num")->get("transactions");
$r = $s->row();
if(isset($r->num)) return $r->num;
return 0;
return $result[0]->Transactions;
}
function get_pending_dash($user)
{
$where = "status = '1' AND type = '2'";
return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
}
因为在你的函数中 get_pending_dash 需要 $user
作为参数,但是根据你的代码你也没有使用它所以如果你没有使用参数就删除 $user
喜欢下面的代码。
function get_pending_dash()
{
$where = "status = '1' AND type = '2'";
return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
}