MySQL: How to consume/discard the result of a query?

Posted by GetFree on Stack Overflow See other posts from Stack Overflow or by GetFree
Published on 2010-05-28T19:43:37Z Indexed on 2010/05/28 19:52 UTC
Read the original article Hit count: 186

I have a stored procedure which executes an optimize table statement for every table in a DB. Those optimize table statements are prepared statements of course (they have to be built at runtime) and I need to call that procedure from PHP using ext/mysql API.

Unfortunately, ext/mysql does't support doing such thing because optimize table returns a result set and in order to handle that, the new mysql protocol is required, which is supported by the "new" ext/mysqli API.

Well... there are several things I dont have control over, so it's not in my posibilities to upgrade to ext/mysqli any time soon, nor can I implement the procedure as PHP code rather than sql code.
So I thought if it would be possible somehow to consume/discard the result of optimize table inside the stored procedure so that ext/mysql doesn't complain about it.

One thing to consider is that since the optimize table statements are prepared statements, you can't use a cursor over them.

© Stack Overflow or respective owner

Related posts about php

Related posts about sql