php - Propel not adding single quote to fields name in MySql query
Get the solution ↓↓↓I have the following mysql table:
CREATE TABLE `content_segments`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`include` TINYINT(1) NOT NULL,
`dimension` VARCHAR(50) NOT NULL,
`media_type` VARCHAR(50) NOT NULL,
`match` VARCHAR(50) NOT NULL,
`content` TEXT NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
The problem is the match field is reserved word in MySQL, and propel2 doesn't surround the fields name with a single quote to escape the reserved word at run-time (when the query is generated). I wonder if there's a why to force propel escaping all my table fields with single quote to avoid reserved words errors. The error I'm getting is this:
Unable to execute SELECT statement [SELECT id, include, dimension, media_type, match, content FROM content_segments WHERE id = :p0]
Answer
Solution:
The solution is in the issue discussion on propel git repository.
We have changed the way how identifier quoting is working. You need to activate it per database or per table:
<database ... identifierQuoting="true">
or
<table ... identifierQuoting="true">
As it was stated in the comment of the question, the related propel issue is https://github.com/propelorm/Propel2/issues/781 for propel2
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: php undefined array key
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.