LoginSignup
2
0

More than 1 year has passed since last update.

fuel.php Fuel\Core\Database_Exception [ 42000 (1064) ]:エラー

Last updated at Posted at 2021-07-25

fuel.phpのエラーはググっても古い記事が多く、苦戦しました。
本日は以下のエラーと格闘。

Fuel\Core\Database_Exception [ 42000 (1064) ]:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group, profile_fields, last_login, login_hash, created_at)

これはデフォルトで用意しなきゃいけないusersテーブルの中の「group」というテーブルが悪さをしてます。
これは予約語です。
なのでバッククウォートで囲ってあげる必要がありますね。

まずは
fuel>packages>auth>classes>auth>login>simpleauth.php
に入ります。

そこの260行目付近に以下の記述があります。
デフォルトだとgroupがシングルクオーテーションで囲われてるだけなのですが
その内側をバッククウォートで囲ってあげればOKですね。

fuel.php

$user = array(
            'username'        => (string) $username,
            'password'        => $this->hash_password((string) $password),
            'email'           => $email,
                          //こいつです。このやろーーー
            '`group`'           => (int) $group,
            'profile_fields'  => serialize($profile_fields),
            'last_login'      => 0,
            'login_hash'      => '',
            'created_at'      => \Date::forge()->get_timestamp(),
        );

多分SELECTの時とかも悪さをしそうなのでエラー画面からファイル名を特定して書き換えてやる
必要がありそうですね。

2
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
2
0