首页 > 解决方案 > 由于缺少值,函数内的存储过程失败

问题描述

我无法弄清楚我的错误出在哪里,但我正在调用此函数并发送 3 个必需的参数,但该过程在执行时失败。

我添加了一个 dump and die 语句,它打印了程序中使用的所有 4 个参数。我关心的一件事是确保所有 4 件事都作为字符串正确发送,因为它们都应该是过程中的字符串。

也许是别的原因,因为当我将 4 个参数值手动添加到我的 IDE 中时,它们成功地输入了数据库。我如何发送这些值有问题吗?

    function createUser($out2,$email,$access){

        $type = 'web';

        $userStmt = \DB::connection('odbc')->getPdo()->prepare("call schema.insertUser(?,?,?,?)"); 

        $userStmt->bindParam(1, $out2, PDO::PARAM_STR,20);
        $userStmt->bindParam(2, $email, PDO::PARAM_STR,140);
        $userStmt->bindParam(3, $access, PDO::PARAM_STR, 2500);
        $userStmt->bindParam(4, $type, PDO::PARAM_STR, 20);

        dd("Out" . $out2 . "Email" . $email . "Access" . $access . "Type" . $type);
        $userStmt->execute();
    }

转储 $userStmt

PDOStatement {#845 ▼
  +queryString: "call schema.insertuser(?,?,?,?)"
  errorInfo: array:4 [▼
    0 => ""
    1 => 0
    2 => " ((null)[0] at (null):0)"
    3 => ""
  ]
}

标签: phpsql

解决方案


推荐阅读