catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

[Issue] count(*)(count) aliasing count(*) not working #435

Closed hirdeshvishwdewa closed 3 years ago

hirdeshvishwdewa commented 8 years ago
$data = array();
$data['tableName']  = "users";
$data['selectFields'] = array('count(*)(count)'); // OR $data['selectFields'] = 'count(*)(count)';
$data['where'] = array('OR' => array('email[=]' => $user['email'], 'username[=]' => $user['username']));
$medoo = new medoo($this->db);
$medoo->select($data['tableName'], $data['selectFields'], $data['where'])

I want count as an alias of count(*), which I am not getting, instead I am getting a empty result.

This is the sql generated from debug mode.

SELECT AS count FROMusersWHERE email = 'hir@ha.com' OR username = 'hird08A'

Please fix :)

zhangchunsheng commented 8 years ago

I have the same problem with group by. I change the code like this.

$value = preg_replace('/^#.(\)\s/i', "", $value); $stack[ $index ][ $value ] = $data[ $value ];