Closed bootswithdefer closed 3 years ago
Hi,
A simple count query like that:
$total_users = $this['db']->count('python_users');
Leads to an error:
Notice: Undefined variable: afterWhere in /home/djipey/informatique/servers/site_atomik/vendor/atomik/atomik/src/plugins/Db.php on line 108
Looking at the code:
public function selectValue($tableName, $column, $where = null)
{
$stmt = $this->executeSelect($tableName, $column, $where, $afterWhere);
return $stmt->fetchColumn();
}
/**
* Executes a SELECT COUNT(*) on $tableName
*
* @param string $tableName
* @param array|string $where
* @return int
*/
public function count($tableName, $where = null)
{
return $this->selectValue($tableName, 'COUNT(*)', $where);
}
You can see that the function count relies on selectValue, but does not pass the $afterWhere argument to this function. It causes a bug. I will make a PR.
The other select functions have afterWhere, would be nice to have it in selectValue too.