用戶,我想使用類似下面的準備語句來創建數據庫用戶:創建雄辯準備好的語句
DB::statement("CREATE USER ? IDENTIFIED BY ?", ['abc', 'def']);
但是,嘗試運行這給了我一個錯誤:
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 '? IDENTIFIED BY ?' at line 1 (SQL: CREATE USER abc IDENTIFIED BY def)
我可以這樣創建:
DB::statement("CREATE USER {$user} IDENTIFIED BY {$password}");
但是我不想使用預先準備好的語句,我可以做到嗎?
當然,如果你正在使用''參數? – RiggsFolly
'$ user ='abc'; $ passwod ='def'' –