in reply to Re: How can I make DBI's prepare() fail? [MySQL]
in thread How can I make DBI's prepare() fail? [MySQL]

DBD::mysql doesn't do anything in ->prepare

Wait, what? Why am I doing prepare(), then execute()? Just so I can have parameterised queries?

  • Comment on Re^2: How can I make DBI's prepare() fail? [MySQL]

Replies are listed 'Best First'.
Re^3: How can I make DBI's prepare() fail? [MySQL]
by Corion (Patriarch) on Dec 23, 2018 at 10:48 UTC

    You're following ->prepare, ->execute because that's how the DBI API is designed. A DBD is free to do as much or as little work in any of the two steps. I think DBD::mysql merely stores the SQL string in ->prepare and does all the checking etc. in ->execute. You can switch to just using ->selectall_arrayref, but that way you lose easy access to caching. Also, should you ever switch to a different database, it might do more work during ->prepare and thus that phase might raise errors.