laravel存储过程错误

时间:2015-03-17 16:47:04

标签: php mysql laravel

我在尝试使用存储过程注册用户时遇到以下错误 非常感谢任何帮助。

  

错误:SQLSTATE [42000]:语法错误或访问冲突:1318 PROCEDURE的参数数量不正确tls_db.insert_customer;预期7,得0(SQL:call insert_customer)

controller
    $user   = array(
                'email' => Input::get('email'),
                'password' => Input::get('password'),
                'username' => Input::get('username'),
                'PhoneNumber' => Input::get('PhoneNumber'),
                'CustomerName' => Input::get('CustomerName'),
                'CustomerSurname' => Input::get('CustomerSurname'),
                'CustomerAddress' => Input::get('CustomerAddress'));
                $data = new user($user);
                $data->save();
                user::storedProcedureInsert_customer();
                return Redirect::to('/');
model
    public static function storedProcedureInsert_customer() {
         return DB::statement('call insert_customer');
    } 

1 个答案:

答案 0 :(得分:0)

您的insert_customer程序需要七个参数,但您没有提供任何参数。

最好用参数化语句调用它,如下所示:

DB::statement('call insert_customer(?, ?, ?, ?, ?, ?, ?)', [Input::get('email'), Input::get('password'), Input::get('PhoneNumber'), Input::get('CustomerName'), Input::get('CustomerSurname'), Input::get('CustomerAddress')]);