Zend Framework - counting rows in select clause ?
- by moogeek
Hello! I'm investigating Zend Framework and currently stucked in counting resulting rows of sql query... Every method I try (from documentation and some blogposts and tutorials) returns an error (like Call to undefined function) or simply gives the incorrect value.
I've tried this:
$checkquery = $db->select()
->from('users', 'COUNT(*)')
->where('login = ?', $login)
->where('password = ?', $password)
->query();
$checkrequest=fetchRow($checkquery)->num;
...then this one:
$checkquery = $db->select()
->from('users', '*')
->where('login = ?', $login)
->where('password = ?', $password)
->query();
$checkrequest=count($checkquery->fetchAll());
and even:
$checkquery = $db->select()
->from('users', '*')
->where('login = ?', $login)
->where('password = ?', $password)
->query();
$checkrequest=$checkquery->fetchAll()->num;
Also rowCount() and count(fetchRow()) and count(fetchAll()->toArray()). But always I got an error message or duplicate inserts in db in further insert function. So what is the correct way to do the resulting row calculation in select clause in Zend Framework 1.9 (I use this one) ?