[英]Kohana, how to get the result of $query->execute()
$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 [ Fatal Error ]: Call to a member function count() on a non-object ErrorException [致命错误]:在非对象上调用成员函数count()
how to get the result of query?anybody help ..thx.. 如何获得查询结果?有人帮助..thx ..
If $result = $query->execute()->as_array() ;
如果
$result = $query->execute()->as_array() ;
returns an array, your if statement should be 返回一个数组,您的if语句应为
if (count($result) > 0)
{
return $result ;
}
else
{
return null ;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.