LoginSignup
1
0

More than 1 year has passed since last update.

カラム名に予約語を使ってしまっている場合のインサート方法

Last updated at Posted at 2022-05-25

メモ

カラム名に予約語を使ってしまっている場合に、データをインサートしようとすると以下のエラーがでてしまった。

"SQLSTATE[42000]: Syntax error or access violation:
to your MariaDB server version for the right syntax to use near 'fro line 1"

Entityファイルの

    /**
     * @var string
     *
     * @ORM\Column(name="`from`", type="decimal", precision=12, scale=2, options={"unsigned":true})
     */
    private $from;

name="" の中のカラム名に`を付けるだけ

カラム名を変更したくないと思い、解決策を探していたら1時間以上かかった。。。

予約語って名前自体聞いたことがなかったので調べるのに苦労しました
「反応しないカラム名」、「カラム名 効かない」、「カラム名 構文エラー」とか・・・。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0