0

I have a sql error deploying my symfony project on Unix. Indeed, the query made uses uppercase for table names which was not the case before. In the database, table names are lowercases.

Does anybody know where you configure how you want the queries generation be made (uppercase or lowercase)

Thank you.

Maybe something in Doctrine configuration??

NOTE : I have some new information.

I asked to rebuild my database from the save at a time I know it was working. I have some errors because, for the new code, the database must be a little different than what it was at this time but I can see that in queries the names of the tables are in lower case. I pass my new sql (the same as before plus some little changes) in command line.

\. path/to/my/sql

I launch the site and queries are made with table names in uppercase.

Got any idea ?

example of entity :

<?php

namespace MyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * MyTable
 *
 * @ORM\Table(name="mytable")
 * @ORM\Entity(repositoryClass="MyBundle\Repository\MyClassRepository")
 */
class MyTable
{
  /**
   * @var string
   *
   * @ORM\Column(name="FIELD1, type="string", length=120, nullable=false)
   */
  private $field1;

  /**
   * @var string
   *
   * @ORM\Column(name="FIELD2", type="string", length=50, nullable=true)
   */
  private $field2

  /**
   * Set field1
   *
   * @param string $field1
   *
   * @return Tretb
   */
  public function setField1($field1)
  {
    $this->field1 = $field1;

    return $this;
  }

  /**
   * Get field1
   *
   * @return string
   */
  public function getField1()
  {
    return $this->field1;
  }

  /**
   * Set field2
   *
   * @param string $field2
   *
   * @return Tretb
   */
  public function setField2($field2)
  {
    $this->field2 = $field2;

    return $this;
  }

  /**
   * Get field2
   *
   * @return string
   */
  public function getField2()
  {
    return $this->field2;
  }
}
mlwacosmos
  • 4,391
  • 16
  • 66
  • 114
  • Please provide at least an example Entity and an example Controller, this may help to find the problem. – Florian Sep 07 '16 at 13:41

2 Answers2

1

Dont know if you can configure it more generally, but you can define table table for each entity with doctrine

/**
 * AppBundle\Entity\MyEntity
 *
 * @ORM\Table()
 * @ORM\Entity
 * @ORM\Table(name="mytable")
 */
class MyEntity
{
Chuck Norris
  • 1,125
  • 1
  • 12
  • 28
0

Does your MySQL instance support lowercase tablenames ? To check the settings use:

mysql> show variables like "lower_case%";

To change the setting you need to change the mysql setting

lower_case_table_names = 1 or lower_case_table_names = 2

Source from Stackoverflow

Community
  • 1
  • 1
Florian
  • 845
  • 1
  • 9
  • 17
  • what is the instruction to put 1 or 2 to lower_case_table_names ? – mlwacosmos Sep 06 '16 at 12:42
  • Another thing I dont get... why is it not writing the sql queries with column names and table names written like in the annotations ? – mlwacosmos Sep 06 '16 at 12:43
  • If you're changing the option within the mysql console it is not working. You need to change it in your mysql.ini or my.conf file. – Florian Sep 07 '16 at 08:15
  • Could you also provide an example Entity from your Code for us? – Florian Sep 07 '16 at 08:15
  • the server configuration depends on somebody else... plus, before, it used to work though they did not change anything in the configuration – mlwacosmos Sep 07 '16 at 13:21