osdir.com
mailing list archive

Subject: Re: Multiple Inserts with mySQL - msg#00471

List: php.database

Date: Prev Next Index Thread: Prev Next Index
hmm, I guess that would work. There is no way to have mySQL check for integrity for me is there? I read in a SQL book a while ago about wrapping multiple inserts in a select statement, that way if any part of the statement failed the whole thing would be rolled back. From my research though, it doesn't look like mySQL supports this. Am I right here? So far it looks like your idea could be the most reliable suggestions I've gotten, so I'll start working on that for now. Thanks.

- Anthony

Peter Beckman wrote:
Try this:

$stack is an array of hashes:

$stack[0] = array(0=>tablename, 1=>insertid());

For each insert you do, push an anonymous array on $stack which includes
the tablename and insertid of the insert.

Then as you continue your inserts, if any of them fail, call a function
which takes that array $stack, and iterate through it, deleting the rows
you just inserted. (see mysql_insert_id() function to get the insert ID)

If none of them do fail, then you are in the clear. Either unset $stack or
ignore it.

Peter

On Wed, 13 Nov 2002, Anthony wrote:


I have to drop a lot of data into mySQL from PHP. It will go into quite
a few different tables. How can I maintain integrity of the entire
insert? I need to do about a dozen inserts on four tables and I need to
insure that all the inserts are successful or that none of them get
done. I'm sort of new at this, so please help me out. Thanks.

- Anthony


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



---------------------------------------------------------------------------
Peter Beckman Systems Engineer, Fairfax Cable Access Corporation
beckman@xxxxxxxxxxxxx http://www.purplecow.com/
---------------------------------------------------------------------------



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

RE: Best reporting Tool

I have to agree on the PDF. Currently my host does not provide for PDF capabilities as of yet but I believe they are going to be compiling with support for PDF soon. When they do, look out. The success of some of our commercial apps will rise for sure as this reporting options becomes available. A lot of our apps/tools are for customers of our clients... meaning our clients (marketing and Ad firms) utilize our tools to sell to their clients therefore a lot of the reports need to be made available to their clients as well. PDF files will really enhance the client-relationship thus making it that much stronger and a longer lasting business relationship (more$$$$$). Just my thoughts. Aaron -----Original Message----- From: John KRewson [mailto:krewsonj@xxxxxxxxxxxxxx] Sent: November 14, 2002 10:47 AM To: php-db@xxxxxxxxxxxxx Subject: Re: [PHP-DB] Best reporting Tool I have recently been creating reports using PHP's pdf libraries. Somewhat time consuming to develop them from scratch and the client has to have the acrobat reader, but they look slick, I must say. Another option is to create RTF or PDF templates and simply replace certain areas with your data. This might not be what you are looking for, but a couple of places to start: http://zope1.devshed.com/zope.devshed.com/Server_Side/PHP/PDF/page1.html http://www.phpbuilder.com/columns/perugini20001026.php3 One nice thing about this is that quite a few people seem to be developing classes for this kind of reporting. Mohammad Saad wrote: >Hi, I wanted to ask a question, Whats the best way of developing reports in >PHP. I mean in case of ASP, developers use Crystal Reports but apparently >PHP doesn't support Crystal Reports. so is there any other tool for me? or >should I use conventional method of writing database queries, PHP paging and >HTML table formatting to generate reports. The reason I am asking is this, >that for a particular project I need to come up with around 175 reports, >Although am sure some of the reports formats will be the same so I can just >switch queries in those. but still is there any other better way out, are >Oracle Reports supported in PHP? > >Thanks in Advance >Saad > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Next Message by Date: click to view message preview

Re: Multiple Inserts with mySQL

hmm, I guess that would work. There is no way to have mySQL check for integrity for me is there? I read in a SQL book a while ago about wrapping multiple inserts in a select statement, that way if any part of the statement failed the whole thing would be rolled back. From my research though, it doesn't look like mySQL supports this. Am I right here? So far it looks like your idea could be the most reliable suggestions I've gotten, so I'll start working on that for now. Thanks. - Anthony Peter Beckman wrote: Try this: $stack is an array of hashes: $stack[0] = array(0=>tablename, 1=>insertid()); For each insert you do, push an anonymous array on $stack which includes the tablename and insertid of the insert. Then as you continue your inserts, if any of them fail, call a function which takes that array $stack, and iterate through it, deleting the rows you just inserted. (see mysql_insert_id() function to get the insert ID) If none of them do fail, then you are in the clear. Either unset $stack or ignore it. Peter On Wed, 13 Nov 2002, Anthony wrote: I have to drop a lot of data into mySQL from PHP. It will go into quite a few different tables. How can I maintain integrity of the entire insert? I need to do about a dozen inserts on four tables and I need to insure that all the inserts are successful or that none of them get done. I'm sort of new at this, so please help me out. Thanks. - Anthony -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --------------------------------------------------------------------------- Peter Beckman Systems Engineer, Fairfax Cable Access Corporation beckman@xxxxxxxxxxxxx http://www.purplecow.com/ --------------------------------------------------------------------------- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Previous Message by Thread: click to view message preview

Re: Multiple Inserts with mySQL

Try this: $stack is an array of hashes: $stack[0] = array(0=>tablename, 1=>insertid()); For each insert you do, push an anonymous array on $stack which includes the tablename and insertid of the insert. Then as you continue your inserts, if any of them fail, call a function which takes that array $stack, and iterate through it, deleting the rows you just inserted. (see mysql_insert_id() function to get the insert ID) If none of them do fail, then you are in the clear. Either unset $stack or ignore it. Peter On Wed, 13 Nov 2002, Anthony wrote: > I have to drop a lot of data into mySQL from PHP. It will go into quite > a few different tables. How can I maintain integrity of the entire > insert? I need to do about a dozen inserts on four tables and I need to > insure that all the inserts are successful or that none of them get > done. I'm sort of new at this, so please help me out. Thanks. > > - Anthony > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --------------------------------------------------------------------------- Peter Beckman Systems Engineer, Fairfax Cable Access Corporation beckman@xxxxxxxxxxxxx http://www.purplecow.com/ --------------------------------------------------------------------------- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Next Message by Thread: click to view message preview

Re: Multiple Inserts with mySQL

hmm, I guess that would work. There is no way to have mySQL check for integrity for me is there? I read in a SQL book a while ago about wrapping multiple inserts in a select statement, that way if any part of the statement failed the whole thing would be rolled back. From my research though, it doesn't look like mySQL supports this. Am I right here? So far it looks like your idea could be the most reliable suggestions I've gotten, so I'll start working on that for now. Thanks. - Anthony Peter Beckman wrote: Try this: $stack is an array of hashes: $stack[0] = array(0=>tablename, 1=>insertid()); For each insert you do, push an anonymous array on $stack which includes the tablename and insertid of the insert. Then as you continue your inserts, if any of them fail, call a function which takes that array $stack, and iterate through it, deleting the rows you just inserted. (see mysql_insert_id() function to get the insert ID) If none of them do fail, then you are in the clear. Either unset $stack or ignore it. Peter On Wed, 13 Nov 2002, Anthony wrote: I have to drop a lot of data into mySQL from PHP. It will go into quite a few different tables. How can I maintain integrity of the entire insert? I need to do about a dozen inserts on four tables and I need to insure that all the inserts are successful or that none of them get done. I'm sort of new at this, so please help me out. Thanks. - Anthony -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --------------------------------------------------------------------------- Peter Beckman Systems Engineer, Fairfax Cable Access Corporation beckman@xxxxxxxxxxxxx http://www.purplecow.com/ --------------------------------------------------------------------------- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by