Question

I have following sql error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.`role`' in 'field list'

My doctrine select is

$query->select('a.role AS role');

When i look on the symfony error i see that doctrine makes the 'a.role' to a.role.

Here the full SQL Statement =

at Doctrine_Connection->execute('SELECT `a`.```role``` AS `a__0`, `a`.`role` AS `a__0` FROM `offer` `o` INNER JOIN `account` `a` *******)
Was it helpful?

Solution

It is best practice to not even use backticks. The only time they are necessary is when you are using tables that are reserved words, and it is suggested you don't do that in the first place.

Turn off quoting by using the quote_identifier attribute in your databases.yml. An example of the output is referenced here.

Example databases.yml:

default:
  class:          sfDoctrineDatabase
    param:
      dsn: mysql:dbname=database_name;host=localhost
      username: username
      password: password
    attributes:
      quote_identifier: false
      use_native_enum: false
      validate: all
      default_table_charset: utf8
      default_table_collate: utf8_general_ci
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top