0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

今回ハマったPHPのexecuteのおはなし

Posted at

少し前に、ハマったところのmemo

executeにパラメータを付けるときはarrayが絶対必要ということ

PHPでプリペアドステートメントを実行する際、executeにパラメータを付けるときはarrayが絶対必要ということ

今回、プリペアドステートメントを用意、実行する際にSQLに入れ込む値が1つだったので
execute(array( $value ))のようにしなくても良いと勝手に判断してしまい、
execute( $value )のように行ったところ実行されなかった。

たとえ、値が1つだろうが、2つだろうが配列で渡さないといけないという概念がなかったのと
勝手に書式を変えてしまったのが大きな原因でした。

PHPリファレンス PDOStatement::execute

やはりエラーが起こった時点で、ある程度問題の箇所を絞ってそれからphp.netのマニュアルを
よく読んで進めていかなければいけないな、と再確認させてもらいました。

ご教授してくださったメンターさんに感謝しております。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?