php - PDO gives error, but MYSQL returns correct result -


i'm using mysql php. here want do.

select    pr.name,   us.group group_name   profiles pr inner join   users on (pr.username = us.username)   us.group = 'group_name'; 

this works when type directly mysql. when php, get

fatal erro: uncaught exception 'pdoexception' message 'database query failed (sql error 42s22): 1054: unknown column 'us.group' in 'where clause' ... 

here code.

public function foo($group) {     $sql = "select                pr.name,               us.group group_name                           profiles pr             inner join               users on (pr.username = us.username)";      $criteria = array();     $args = array();      $criteria[] = "us.group = ?"     $args = $group;      if($criteria) { $sql .= " ".implode(" , ", $criteria); }      return dbconnection::query($sql, $args)->fetchall(pdo::fetch_assoc); } 


Comments