i cant get it why it is not working
$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'];
The DEBUG DUMP PARAMS RETURNS THIS
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
Why everytime i am getting empty result? anything wrong in this code. please help.
MySQL要求您使用缓冲的查询 ,因为在获取所有行之前, rowCount()
方法无法知道结果集中有多少行。
Try this..
$rowCount = $pdo->query('select count(*) from blah')->fetchColumn();
if(count($rowCount) > 0)
{
//Your code here
} else {
die();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.