Symfony 3.4,FOSUserBundle:SQL postgresql 错误
Symfony 3.4, FOSUserBundle: SQL Errors with postgresql
我有一个只有 id 属性的普通用户 class 在我使用 MySQL 时工作得很好。自从我改用 Postgresql 后,我开始遇到很多问题。
首先让我概述一下我的应用程序,它是一个网络上的 GIS,我放置了一个 TSV 文件和一个我制作的 php 脚本,它读取 TSV 文件并将其数据保存在数据库。然后 Geoserver 读取数据并将其提供给我的传单地图。所以 Postgresql 非常重要,因为 Geoserver 不支持 MySQL.
起初我使用命令行工具创建了数据库及其模式。到这里为止一切都很好,但是当我尝试使用命令行创建用户时,它会抛出 SQLSTATE[42601] 语法错误:
In AbstractPostgreSQLDriver.php line 70:
An exception occurred while executing 'INSERT INTO user (username, username_canonical, emai
l, email_canonical, enabled, salt, password, last_login, confirmation_token, password_reque
sted_at, roles, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["admin", "adm
in", "admin@ferrybox.tk", "admin@ferrybox.tk", 1, null, "y$rS4j9aDRRpKMA2ge3QoDNuhmCWD
9cO9Cmnzv\/PxqUmBxSximXcFZu", null, null, null, "a:0:{}", 1]:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
In PDOStatement.php line 107:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
In PDOStatement.php line 105:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
Sorry about the french sentence it says basicly error of syntax on or
near << user >>
这不是我遇到的唯一一个问题,在这种方法不起作用之后我尝试使用注册表单:
An exception occurred while executing 'SELECT t0.username AS username_1, t0.username_canonical AS username_canonical_2, t0.email AS email_3, t0.email_canonical AS email_canonical_4, t0.enabled AS enabled_5, t0.salt AS salt_6, t0.password AS password_7, t0.last_login AS last_login_8, t0.confirmation_token AS confirmation_token_9, t0.password_requested_at AS password_requested_at_10, t0.roles AS roles_11, t0.id AS id_12 FROM user t0 WHERE t0.username_canonical = ?' with params ["user"]:
SQLSTATE[42703]: Undefined column: 7 ERREUR: la colonne t0.username n'existe pas
LINE 1: SELECT t0.username AS username_1, t0.username_canonical AS u...
^
即使我尝试手动将用户输入数据库,但是当我尝试登录时:
Authentication request could not be processed due to a system problem.
我不知道我制作的其他实体是否正常工作,因为我无法进入管理面板使用它们。
<?php
namespace AdminBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use SbS\AdminLTEBundle\Model\UserInterface as ThemeUser;
use Doctrine\ORM\Mapping as ORM;
/**
* Class User
* @package AdminBundle\Entity
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User extends BaseUser implements ThemeUser
{
/**
* @var int
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
}
/**
* Get Id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set Id
*
* @param int $id
*
* @return User
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Should return FirstName and LastName
* @return string
*/
public function getName()
{
}
/**
* Should return path to avatar. See Twig User Extension.
* @return string
*/
public function getAvatar()
{
}
/**
* Should return Date of Registration
* @return mixed
*/
public function getMemberSince()
{
}
/**
* Should return Description (can be role, group or etc.)
* @return string
*/
public function getTitle()
{
}
/**
* Can return Additional Info
* @return mixed
*/
public function getInfo()
{
}
}
ThemeUser is an interface of an admin bundle that i am using, i just
implemented it to have the bundle fonctionality. It didnt have any
issue when i was using MySQL. I even didnt fill the methods cuz i dont need them.
Column Type Comment
id integer
username varchar(180)
username_canonical varchar(180)
email varchar(180)
email_canonical varchar(180)
enabled boolean
salt varchar(255) NULL
password varchar(255)
last_login timestamp(0) NULL
confirmation_token varchar(180) NULL
password_requested_at timestamp(0) NULL
roles text (DC2Type:array)
"user" 是 postgreSQL 中的保留关键字,您应该将 table 名称更改为其他名称,或添加“`”(反引号)符号
`user`
https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
我有一个只有 id 属性的普通用户 class 在我使用 MySQL 时工作得很好。自从我改用 Postgresql 后,我开始遇到很多问题。
首先让我概述一下我的应用程序,它是一个网络上的 GIS,我放置了一个 TSV 文件和一个我制作的 php 脚本,它读取 TSV 文件并将其数据保存在数据库。然后 Geoserver 读取数据并将其提供给我的传单地图。所以 Postgresql 非常重要,因为 Geoserver 不支持 MySQL.
起初我使用命令行工具创建了数据库及其模式。到这里为止一切都很好,但是当我尝试使用命令行创建用户时,它会抛出 SQLSTATE[42601] 语法错误:
In AbstractPostgreSQLDriver.php line 70:
An exception occurred while executing 'INSERT INTO user (username, username_canonical, emai
l, email_canonical, enabled, salt, password, last_login, confirmation_token, password_reque
sted_at, roles, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["admin", "adm
in", "admin@ferrybox.tk", "admin@ferrybox.tk", 1, null, "y$rS4j9aDRRpKMA2ge3QoDNuhmCWD
9cO9Cmnzv\/PxqUmBxSximXcFZu", null, null, null, "a:0:{}", 1]:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
In PDOStatement.php line 107:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
In PDOStatement.php line 105:
SQLSTATE[42601]: Syntax error: 7 ERREUR: erreur de syntaxe sur ou près de « user »
LINE 1: INSERT INTO user (username, username_canonical, email, email...
^
Sorry about the french sentence it says basicly error of syntax on or near << user >>
这不是我遇到的唯一一个问题,在这种方法不起作用之后我尝试使用注册表单:
An exception occurred while executing 'SELECT t0.username AS username_1, t0.username_canonical AS username_canonical_2, t0.email AS email_3, t0.email_canonical AS email_canonical_4, t0.enabled AS enabled_5, t0.salt AS salt_6, t0.password AS password_7, t0.last_login AS last_login_8, t0.confirmation_token AS confirmation_token_9, t0.password_requested_at AS password_requested_at_10, t0.roles AS roles_11, t0.id AS id_12 FROM user t0 WHERE t0.username_canonical = ?' with params ["user"]:
SQLSTATE[42703]: Undefined column: 7 ERREUR: la colonne t0.username n'existe pas
LINE 1: SELECT t0.username AS username_1, t0.username_canonical AS u...
^
即使我尝试手动将用户输入数据库,但是当我尝试登录时:
Authentication request could not be processed due to a system problem.
我不知道我制作的其他实体是否正常工作,因为我无法进入管理面板使用它们。
<?php
namespace AdminBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use SbS\AdminLTEBundle\Model\UserInterface as ThemeUser;
use Doctrine\ORM\Mapping as ORM;
/**
* Class User
* @package AdminBundle\Entity
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User extends BaseUser implements ThemeUser
{
/**
* @var int
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
}
/**
* Get Id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set Id
*
* @param int $id
*
* @return User
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Should return FirstName and LastName
* @return string
*/
public function getName()
{
}
/**
* Should return path to avatar. See Twig User Extension.
* @return string
*/
public function getAvatar()
{
}
/**
* Should return Date of Registration
* @return mixed
*/
public function getMemberSince()
{
}
/**
* Should return Description (can be role, group or etc.)
* @return string
*/
public function getTitle()
{
}
/**
* Can return Additional Info
* @return mixed
*/
public function getInfo()
{
}
}
ThemeUser is an interface of an admin bundle that i am using, i just implemented it to have the bundle fonctionality. It didnt have any issue when i was using MySQL. I even didnt fill the methods cuz i dont need them.
Column Type Comment
id integer
username varchar(180)
username_canonical varchar(180)
email varchar(180)
email_canonical varchar(180)
enabled boolean
salt varchar(255) NULL
password varchar(255)
last_login timestamp(0) NULL
confirmation_token varchar(180) NULL
password_requested_at timestamp(0) NULL
roles text (DC2Type:array)
"user" 是 postgreSQL 中的保留关键字,您应该将 table 名称更改为其他名称,或添加“`”(反引号)符号
`user`
https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html