zepernick / Codeigniter-DataTables

CodeIgniter Library For Ajax Server Side DataTables 1.10 >
MIT License
94 stars 95 forks source link

_protect_identifiers = False -> only if needed? #9

Closed fipsofant closed 8 years ago

fipsofant commented 9 years ago

Hey, I am still quite new to CI3, but my project need _protect_identifiers = TRUE. So I would like to know if there is a possibility to switch to FALSE only if the function appendToSelectStr is issued?

Thanks

zepernick commented 9 years ago

I will make a change to be able to enable or disabled them. You should be able to manually add in the `` around the name that needs to be escaped. I should be able to get to this sometime today.

fipsofant commented 9 years ago

Well i tried to add backticks but the function create a strange query: Model:

public function appendToSelectStr() {
            return array(
                'customerFullname' => 'concat(`customer_firstname`, `customer_lastname`)'
                );
        }

Query:

SELECT `customer_id`, concat(`customer_firstname`, `customer_lastname``)` `customerFullname`
FROM `table_customers`

I tried to remove the second backtick like:

'customerFullname' => 'concat(`customer_firstname`, `customer_lastname)'

then the query look like this:

SELECT `customer_id`, concat(`customer_firstname`, `customer_lastname)` `customerFullname`
FROM `table_customers`

Do you have an idea?

ErvinLlojku commented 8 years ago

Hello, you can try to do something like this

'customerFullname' => 'concat(customer_firstname, \' / \', customer_lastname, \'  \')'
zepernick commented 8 years ago

I have released a new version that allows specification of the protect identifiers for the library.

https://github.com/zepernick/Codeigniter-DataTables/releases/tag/v1.3

It is set to FALSE by default, but setProtectIdentifiers(TRUE) can be called if needed