Jump to content


Photo

Multiple update / insert's in one query?


  • Please log in to reply
2 replies to this topic

#1 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 26 March 2006 - 08:42 AM

So on my forums I notice I am using a lot of queries to get what I need done, which is not so good in practice. Is there a wat to update or insert different data into multiple tables using one query? (Updates and inserts in different queries) ? Not sure if it's even possible :(

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 26 March 2006 - 07:10 PM

Not really, but PHP's mysqli extension has a mysqli_multi_query() function that sends several queries at once. mysqli is still not supported by a lot of web hosts though.

#3 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 26 March 2006 - 07:17 PM

The best thing you can do here ( involves a bit more work) is to re-think your code, see if you can't get all the insert/update data in one place so you only have to run 1, possibly 2 queries per table.

This depends on what your doing but if it's a placement issue that causes you to run 2 queries on the same table you can throw some data into a temporary $_SESSION, then extract it from the array when your ready to run the query, that can help cut down on the amount of queries.
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users