[eluser]davidbehler[/eluser]
I do the following:
Code:
$this->db->select('*');
$this->db->select('(SELECT COUNT(*) FROM user_group WHERE user_group_group_id = group_id) AS user_count', FALSE);
$this->db->order_by('group_name', 'asc');
$result = $this->db->get('group');
The generated query is
Code:
SELECT *, (SELECT COUNT(*) FROM user_group WHERE user_group_group_id = group_id) AS user_count FROM (group) ORDER BY group_name asc
That produces an error caused by the not escaped table name 'group'.
BUT as soon as I leave out the custom select part like this:
Code:
$this->db->select('*');
$this->db->order_by('group_name', 'asc');
$result = $this->db->get('group');
It works fine and the query looks like this:
Code:
SELECT * FROM (`group`) ORDER BY `group_name` asc
As you can see in my second example the table name is escaped just as it should be.
Am I missing something or is this a bug caused by the 'do not escape' parameter of the select method?