dongren4147 2014-11-05 05:50
浏览 16

PDO语句不在实时主机上工作

PDO statements work on localhost but fail to work on a live host. here is an example that works fine on localhost but rowCount() always returns 0 on a live host. someone please help me.

$stmt = $pdo->prepare("SELECT * FROM customer WHERE email = :email AND password = :password");
        $stmt->execute(array(
            ':email' => $uemail,
            ':password' => $pass
        ));
        $count = $stmt->rowCount();
  • 写回答

1条回答 默认 最新

  • douyan4958 2014-11-05 06:01
    关注

    PDOStatement::rowCount

    PDOStatement::rowCount() returns the number of rows affected by a DELETE, INSERT, or UPDATE statement.

    That does not work for SELECT, ironic but true :)

    Workaround:

    For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of rows that will be returned. Your application can then perform the correct action.

    Should not even work on localhost. You're interpreting the result incorrectly on localhost.

    Manual

    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测