Php 如何将参数从控制器发送到具有多个不同参数的模型?
我的控制器是这样的:Php 如何将参数从控制器发送到具有多个不同参数的模型?,php,codeigniter,Php,Codeigniter,我的控制器是这样的: function a() { ... $notification = $this->notification_model->get_notification($session['customer_id'], 10); ... } function b() { ... $new_notification = $this->notification_model->get_notification($session
function a()
{
...
$notification = $this->notification_model->get_notification($session['customer_id'], 10);
...
}
function b()
{
...
$new_notification = $this->notification_model->get_notification($session['customer_id'], 1, "notification_new");
...
}
function get_notification($customer_id, $limit, $is_notif)
{
...
}
我的模型是这样的:
function a()
{
...
$notification = $this->notification_model->get_notification($session['customer_id'], 10);
...
}
function b()
{
...
$new_notification = $this->notification_model->get_notification($session['customer_id'], 1, "notification_new");
...
}
function get_notification($customer_id, $limit, $is_notif)
{
...
}
传递的参数数:
在函数a中:2参数
在函数b中:3参数
在功能(模型)中:3个参数
执行时,存在如下错误:消息:丢失
论据3
这是因为参数不同
有什么解决我的问题的方法吗?在模型函数中,您可以在函数a()中将第三个参数的默认值设置为null
阅读使函数如下
function get_notification($customer_id, $limit, $is_notif=NULL)
{
}
希望能帮助你