@Jordan: I realize MySQL supports transactions and how they work, my
question is more how to send a full transaction in a single query. :-)

@Jonathan: That's kind of what I'm trying to avoid here -- to me, at least,
it seems less efficient to separately send each query to the server than to
send the full group at once, particularly if I really don't want or need to
check the specific result of each individual query in the transaction.

The application in question has several insert statements, which insert into
several tables and perform updates, then selects the insert ID at the end of
the transaction. From the application's point of view, it really doesn't
have to care about the result of each individual insert, as it just sends
the full query and checks to see if it was successful or not.

@Sean and Lonnie: Thanks. I thought I had seen that in mysqli at some point,
but completely missed the multi_query function when I looked this morning. I
think that will probably accomplish what I'm after. And I agree that sending
some of the queries separately and checking so that I can manually issue a
rollback is more desirable for most cases, but at least for this one, I just
need to replicate the existing functionality for the time being.

Thanks for the input!

Michael


On Fri, Sep 10, 2010 at 2:17 PM, Jordan Schatz <[email protected]>wrote:

> > Since mysql_query doesn't support multiple queries per statement, what is
> the best way to do this in PHP? Right now I'm using a transaction class to
> put each query in an array and loop them, but efficiently handling any
> return results is a bit of a puzzle.
>
> MySQL _does_ support transactions. You just have to use the InnoDB
> storage engine (included, but not set as default in my Debian
> installs). You can see which storage engines are supported with " show
> engines"
> http://www.mysql.com/news-and-events/generate-article.php?id=2002_11
>
> -Jordan
>

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to