2

Hi i'm using Symfony and i'm trying to connect my project to a PostgreSQL server version 9.6. I'have already edited the .env file. Then i did my migrations. So I have my new tables in the database, but when i'm creating an account in my web app i have this error.

An exception occurred while executing 'SELECT t0.id AS id_1, t0.username AS username_2, t0.password AS password_3, t0.email AS email_4, t0.confirmation_token AS confirmation_token_5, t0.account_activated AS account_activated_6 FROM user t0 WHERE t0.email = ?' with params ["[email protected]"]:

SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist
LINE 1: SELECT t0.id AS id_1, t0.username AS username_2, t0.password...

I've already used

php bin/console doctrine:schema:update --force

But it changed nothing. I have also added the corrects extensions to the php.ini file.

2 Answers 2

8

In future, instead of changing table name, add @ORM\Table(name="user"). as shown below. Note the the grave accent ( ` ) diacritical mark.

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
 * @ORM\Table(name="`user`")
 * @UniqueEntity(fields={"username"}, message="There is already an account with this username")
 */
class User implements UserInterface
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */

.....the rest of code continues...

Sign up to request clarification or add additional context in comments.

Comments

4

Finally found an issue : "user" is keyword in postgreSQL. I renamed my entity and made migrations. Now it's working

Comments

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.