我刚开始使用PDO,但我对使用bindParam函数有点困惑。是否有可能避免使用bindParam?如果不是-为什么?
我正在使用这样的存储过程
$e = 'example@g.com';
$p = 'pass123';
$stmt = $dbh->prepare("CALL GetUserByEmail($e, $p) );
$stmt->execute();然后,我想检查结果表中有多少个结果。为什么我也不知道怎么做-我已经习惯了使用mysqli_函数。谢谢!
发布于 2014-04-13 12:46:11
当您有准备好的语句时,调用它上的execute函数,其中参数数组是唯一的参数。
命名参数和“有序”参数之间有一个区别:第一个参数有一个名称(关联数组),后者只有一个位置(普通数组)。
示例:
$stmt = $dbh->prepare("CALL GetUserByEmail(?, ?)");
$stmt -> execute(array($e, $p));
$stmt = $dbh->prepare("CALL GetUserByEmail(:emails, :passwords)");
$stmt -> execute(array(':emails' => $e, ':passwords' => $p));还请参阅文档:http://www.php.net/manual/en/pdostatement.execute.php。
要获得行数,请对结果调用rowCount函数:
$stmt -> rowCount(); // Amount of rows selectedhttps://stackoverflow.com/questions/23039114
复制相似问题