Code as follows:
$db = DatabaseService::getInstance(); //get a database handle,base on pdo
$sql = "select * from authusers where ssouid = '".$ssouid."' order by regtime";
$res = $db->query($sql);
if($res && $res->fetch()) // here is the Problem line
{
//do something
}
else
{
//raise some exception
}
In the problem line,I want the condition to find out whether some record(s) in database has been fetched or not.But I found somehow it didn't always work.Someone suggested me to use select count(*) as num ...
to do this ,but I think that would be some kinda of duplicate query as select * from...
.