CodeIgniter Forums
[Active Records] Disabling the protection of identifiers - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: [Active Records] Disabling the protection of identifiers (/thread-22217.html)



[Active Records] Disabling the protection of identifiers - El Forum - 09-01-2009

[eluser]Clooner[/eluser]
The following statement gives me problems
Code:
$this->db->select('round(produces.price*produces.discount*'.vat().',2) as price');
It causes problems because vat() returns a value of 1.19.

This will generate mysql code which is invalid.
Code:
`round(produces`.`price*produces`.`discount*1`.`19`, `2)`

I tried to use $this->db->protect_identifiers but this function doesn't allow you to disable the backticks. How can I disable the backticks generated for the 1.19 value?


[Active Records] Disabling the protection of identifiers - El Forum - 09-01-2009

[eluser]bretticus[/eluser]
From manual...
Quote:$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.



[Active Records] Disabling the protection of identifiers - El Forum - 09-02-2009

[eluser]Clooner[/eluser]
[quote author="bretticus" date="1251863324"]From manual...[/quote] Stupid me... I was too focused on the $this->db->protect_identifiers which made we not check more of the manual. Thanks bretticus.

The worse thing is that in this post I give the ansmer myself.

I need more sleep


[Active Records] Disabling the protection of identifiers - El Forum - 09-02-2009

[eluser]bretticus[/eluser]
[quote author="clooner" date="1251894048"] Stupid me... I was too focused on the $this->db->protect_identifiers which made we not check more of the manual. Thanks bretticus.

The worse thing is that in this post I give the ansmer myself.

I need more sleep[/quote]

Hahaha. Happens to me all the time! Good thing CI has detailed docs (when you can scrutinize them better when not exhausted.) You're welcome.