Welcome Guest, Not a member yet? Register   Sign In
[Active Record] Select AS Backticks problem
#1

[eluser]Azhari Harahap[/eluser]
Hi

i'm using active record to make my SQL query works with all database egnine, but i have a problem on SELECT AS with PostgreSQL.

For example i have this:
Code:
$this->db->select('Name as GroupName')
$this->db->from('pbk');

In MySQL it'll create:
Code:
SELECT `Name` as GroupName FROM (`pbk`)

In PostgreSQL:
Code:
SELECT "Name" as GroupName FROM "pbk"

But, the result will be different, on MySQL it stay as GroupName, but on PostgreSQL it become groupname (It's because PostgreSQL case-sensitive behavior).

The solution is to add backticks (based on driver) to as/alias field name.
On MySQL:
Code:
SELECT `Name` as `GroupName` FROM (`pbk`)

On PostgreSQL:
Code:
SELECT "Name" as "GroupName" FROM "pbk"

Any way to do this?

It will be nice if there is:
Code:
$this->db->select_as('Name', 'GroupName');


Messages In This Thread
[Active Record] Select AS Backticks problem - by El Forum - 03-05-2011, 12:04 PM
[Active Record] Select AS Backticks problem - by El Forum - 03-08-2011, 12:48 AM
[Active Record] Select AS Backticks problem - by El Forum - 03-08-2011, 01:28 AM
[Active Record] Select AS Backticks problem - by El Forum - 03-08-2011, 04:53 AM
[Active Record] Select AS Backticks problem - by El Forum - 03-11-2011, 03:46 AM
[Active Record] Select AS Backticks problem - by El Forum - 03-11-2011, 03:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB