php - laravel 存储过程错误

标签 php mysql laravel

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

Error: SQLSTATE[42000]: Syntax error or access violation: 1318 Incorrect number of arguments for PROCEDURE tls_db.insert_customer; expected 7, got 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');
    } 

最佳答案

您的 insert_customer 过程需要七个参数,但您尚未提供任何参数。

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

DB::statement('调用 insert_customer(?, ?, ?, ?, ?, ?, ?)', [Input::get('电子邮件'), Input::get('密码' ), 输入::get('电话号码'), 输入::get('客户姓名'), 输入::get('客户姓氏'), 输入::get('客户地址')]);

关于php - laravel 存储过程错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29104933/

相关文章:

php - 是否可以使用 iframe 跟踪来自第三方的 ip 或流量

mysql查询-语法错误-找不到原因

javascript - 使用 laravel 迁移插入数据库时​​,如何附加给定输入的字符串?

node.js - Laravel Elastic Beanstalk,无法安装运行 npm?

php - 我如何使用 <style> 标签将 css 代码添加到 php 文件,当前方法不起作用。

php - Laravel 中间件将变量返回给 Controller

php - Zend Form - 一页中的多个表单和 (CSRF) token 验证

mysql - 获取 6 个表的中位数

php - 我如何使用 php 从 sql 查询创建一个 csv 文件

javascript - JQuery UI Datepicker - MaxDate 排除禁用日期