how to add ` character to sql queries in cakephp 3

前端 未结 2 1524
天涯浪人
天涯浪人 2021-01-27 02:49

I have a table with special fields name such as \'from\' and \'order\'

(this table used with another cms and I can\'t change table structor)

I want add a record

相关标签:
2条回答
  • 2021-01-27 03:04

    You need to add 'quoteIdentifiers' => true in your datasource configuration as stated in the doc

    http://book.cakephp.org/3.0/en/orm/database-basics.html#configuration

    0 讨论(0)
  • 2021-01-27 03:13

    Either you can configure your Datasources from 'quoteIdentifiers' => false to 'quoteIdentifiers' => true at app.php

    OR

    One of your columns is using a column name that is reserved by MySQL.

    As you can see that FROM and ORDER is a reserve word by MYSQL, you can try changing these words from your database tables. Hoping it works.

    For example: "tour_tours" table has a "from" field which makes you the Database Error. so please change these fields from your table and re-try.

    0 讨论(0)
提交回复
热议问题