$query = DB::query(Database::SELECT, "select * from users where username like :username") ;
$query->param(':username', $username) ;
$query->parameters(array(
':username' => '%'. $username. '%'
)) ;
$result = $query->execute()->as_array() ;
if ($result->count() > 0)
{
return $result ;
}
else
{
return null ;
}
ErrorException [致命错误]:在非对象上调用成员函数count()
如何获取查询结果?任何人帮助..thx ..
答案 0 :(得分:2)
如果$result = $query->execute()->as_array() ;
返回数组,则if语句应为
if (count($result) > 0)
{
return $result ;
}
else
{
return null ;
}