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.

4
  • 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? Commented Dec 20, 2016 at 7:08
  • Can't figure it out how to get the query though Commented Dec 20, 2016 at 7:09
  • refer this to print your query cakephp see the compiled SQL Query before execution Commented Dec 20, 2016 at 7: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. Commented Dec 20, 2016 at 7:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.