繁体   English   中英

PHP PDO Select查询未从数据库中选择行

[英]PHP PDO Select query not selecting rows from database

我正在运行此PDO查询:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->execute(array(':sequence' => $_GET["sequence"]));
$result = $stmt->fetch();

从数据库中选择行,但是当我做var_dump($ smtm);时 我得到这个结果:

object(PDOStatement)#2 (1) { ["queryString"]=> string(57) "SELECT * from billing_control where sequence = :sequence " }

我的URL末尾有?sequence=178 ,因此它应该运行SQL:

select * from billing_control where sequence = 178

任何想法我错了吗?

尝试:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$stmt->bindParam(':sequence', $_GET["sequence"])
$stmt->execute();

另一个版本是:

$stmt = $pdo_conn->prepare("SELECT * from billing_control where sequence = ? ");
$stmt->execute(array("%$_GET[sequence]%"));

尝试这个

$query = $pdo_conn->prepare("SELECT * from billing_control where sequence = :sequence ");
$query->bindParam(':sequence', $_GET["sequence"], PDO::PARAM_STR, 255); //I assume that sequence data is string
$result = $query->execute();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM