开发者

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 ;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜