0

I have a cakephp console application with the following code :

$this->Message->save(
    [ "Message" =>
        [
            "delivery_class" => null,
            "user_id" => $user_id,
            "messages_class" => self::MESSAGE_CLASS,
            "project_id" => $project_id,
            "text" => $__MessageTmp,
            "attachment_id" => null,
            "opened" => 0,
            "is_deleted" => 0,
            "created_on" => $__NOW,
            "updated_on" => $__NOW,
        ],
    ]
)

This code is printing the error of PDO::quote and the SQL query error near

'2016-12-20')

I think there is some wrong data formatting in the query but can't figure out why.

M. Ko
  • 563
  • 6
  • 31
  • 1
    I think both created_on and updated_on should be sent as a string(being surrounded by single-quotes like '2016-12-20') to the query. Can you post the query which is being executed and giving you this error? – Anish Chikodi Dec 20 '16 at 07:08
  • Can't figure it out how to get the query though – M. Ko Dec 20 '16 at 07:09
  • refer this to print your query [cakephp see the compiled SQL Query before execution](http://stackoverflow.com/questions/16780482/cakephp-see-the-compiled-sql-query-before-execution) – Anish Chikodi Dec 20 '16 at 07:13
  • Seems like the date issue. I have create the date as `new DateTime()`. Try creating with `date('Y-m-d H:i:s')` fix it. – M. Ko Dec 20 '16 at 07:19

0 Answers0