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 [ Fata开发者_StackOverflow中文版l Error ]: Call to a member function count() on a non-object
how to get the result of query?anybody help ..thx..
If $result = $query->execute()->as_array() ;
returns an array, your if statement should be
if (count($result) > 0)
{
return $result ;
}
else
{
return null ;
}
精彩评论