zepernick/Codeigniter-DataTables

_protect_identifiers = False -> only if needed?

fipsofant opened this issue · 4 comments

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

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.

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?

Hello,
you can try to do something like this

'customerFullname' => 'concat(customer_firstname, \' / \', customer_lastname, \'  \')'

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