Welcome Guest, Not a member yet? Register   Sign In
Prblem about CI database query
#1

[eluser]datactrl[/eluser]
I'm using POstgreSQL. How can a very simple query such as the following will cause an error on CI database query?

select a, b, round(c * 0.5, 2)as d from table1;

If I remove round function and make it as

select a, b, c * 0.5 as d from table1;

Then it works
#2

[eluser]techgnome[/eluser]
What's the error? Are you passing FALSE in the second parameter to prevent the escaping of the field names? Odds are you aren't and so CI is putting backticks around round... making it a field name and not a function call.

-tg
#3

[eluser]Mutsop[/eluser]
I'm no expert in this, but are you sure you can do multiplications within a Round function?
As when I check into the documentation of POstgreSQL I don't seem to find anything about this.
#4

[eluser]datactrl[/eluser]
This is from posgreSQL documnet:
round(v numeric, s int) numeric round to s decimal places round(42.4382, 2) 42.44

The error returned from postgreSQL just said there is an error near round. The 2nd parameter of round is an integer. I put 2 on it to let it round up 2 decimal. I double check the following does work on posgresql 8.3

select round(listprice *2, 2)as price2 from adm_items

tesed on pgAdminIII
#5

[eluser]techgnome[/eluser]
Did you read the rest of what I wrote? About passing FALSE as the second parameter when you call the $this->db->select() method.

-tg
#6

[eluser]datactrl[/eluser]
Thanks a lot, techgnome. I did as ...
$query = $this->db->query($s1, FALSE);
And it works!




Theme © iAndrew 2016 - Forum software by © MyBB