Wednesday, 7 August 2013

Cakephp is adding quotes to my query. How to fix this?

Cakephp is adding quotes to my query. How to fix this?

Cakephp is adding quotes to my field where i do some postgress functions.
I use $this->paginate where the fields array looks like this:
'fields' => array( 'DealRegistration.id',
'DealRegistration.company_name',
'RequestSpecialPrice.total_price',
'RequestSpecialPrice.request_price',
'RequestSpecialPrice.created',
'RequestSpecialPrice.partner_status',
'RequestSpecialPrice.status',
'RequestSpecialPrice.discount',
"**concat('SP',lpad(CAST(RequestSpecialPrice.deal_registration_id as
TEXT),8,'0'))**",
)
The query generated by cake looks like this: SELECT
concat('SP',lpad(CAST("RequestSpecialPrice"."deal_registration_id" AS
"TEXT"),8,'0')) FROM table
If i remove the quotes from "TEXT" then the query works: SELECT
concat('SP',lpad(CAST("RequestSpecialPrice"."deal_registration_id" as
TEXT),8,'0'))) FROM table
How can i force cakephp not to add those quotes?

No comments:

Post a Comment