LoginSignup
3
3

More than 5 years have passed since last update.

CREATE TABLE / ALTER TABLE においてMySQLネイティブのプリペアドステートメントは動作しない

Last updated at Posted at 2017-05-06

何を言っているのかわからないのでPsySHで実験したときの画像↓

スクリーンショット 2017-05-06 12.37.41.png

「PDOの擬似プリペアドステートメントは信頼性に難あり,MySQLネイティブのやつを使っておけ」と言われがちですが,本当に信頼性が低いのはどちらでしょうね?

あと生PDOだとなぜか再現できなかったのですが,Laravelのマイグレーションファイルで以下のようにプレースホルダをダブルクオーテーションで括ると動作するという謎の現象を確認しています。

動作しない
    public function up()
    {
        Schema::table('example', function () {

        });
        DB::statement('ALTER TABLE example COMMENT ?', ['test']);
    }
動作する
    public function up()
    {
        Schema::table('example', function () {

        });
        DB::statement('ALTER TABLE example COMMENT "?"', ['test']);
    }
3
3
3

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
3
3