gpt4 book ai didi

PHP:PDO 为什么这段代码不起作用?

转载 作者:行者123 更新时间:2023-11-30 23:09:18 24 4
gpt4 key购买 nike

我不明白为什么它不起作用

$q1=$conn->prepare('select * from users where username = :data');
$q1->bindParam(':data',$searchdata);//$searchdata is having the value
$q1->execute();

if($q1->rowCount()<1)
{
die('NO results found');
}
$row=$q1->fetch(PDO::FETCH_ASSOC);
echo $row['user_id'];

DEBUG DUMP PARAMS 返回这个

select * from users where match(username) against(:searchd) Params: 1 Key: Name: [8] :searchd paramno=-1 name=[8] ":searchd" is_param=1 param_type=2

为什么每次我得到的结果都是空的?这段代码有什么问题。请帮忙。

最佳答案

MySQL 要求您使用 buffered query , 因为 rowCount() 方法在获取所有行之前无法知道结果集中有多少行。

关于PHP:PDO 为什么这段代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20558276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com