Count results from a select in Kohana

1

I would like to know how do I do the results count for a select on Kohana? I have this code:

public function action_verification() {
    $login = $this->request->post('login');
    $senha = md5($this->request->post('senha'));
    //$result = ORM::factory('usuario')->where('login', '=', $login)->and_where('senha', '=', $senha)->find_all();
    $result = DB::select('*')
            ->from('usuarios')
            ->where('login', '=', $login)
            ->and_where('senha', '=', $senha)
            ->as_object()
            ->execute()
            ->current();
    $session = Session::instance();        
    if (count($result) == 0) {
        $session->set('erro', "Usuário ou senha incorreto!");
        $this->redirect('login');
    } else {
        if ($result->codCliente != 0) {                
            $session->set('nome', $result->login);
            $session->set('active',TRUE);
            $this->redirect('AdminHelpdesk/home');
        } else {
            $this->redirect('admin/home');
        }
    }
}

But it always returns me 1. If I just leave this:

$result = DB::select('*')
            ->from('usuarios')
            ->where('login', '=', $login)
            ->and_where('senha', '=', $senha)
            ->as_object()
            ->execute();

Then it returns me 1 or 0, but in doing so it gives me this error:

  

ErrorException [Notice]: Undefined property: Database_MySQL_Result :: $ codClient

That is, it gives me the error in this if :

if ($result->codCliente != 0) {

Can anyone help me with this?

    
asked by anonymous 28.02.2014 / 21:04

1 answer

1

Try this after $session = Session::instance();

 var_dump($result);

    
28.02.2014 / 21:23