Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » SQL sending 4 SQL querys at once
Closed Thread
Old 03-03-2004, 02:46 PM   #1 (permalink)
 
Newb Techie

Join Date: Mar 2004

Posts: 10

exile

Send a message via Yahoo to exile
Default SQL sending 4 SQL querys at once

I have to add entrys to 4 tables. If something goes wrong and it gets cut off, the whole database indexing is messed up. how can i process the 4 entrys at once in php?
ill get the code a little later, dont have it with me right now.
exile is offline  
Old 03-03-2004, 07:42 PM   #2 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

I'm not sure if this is what you mean, but would something like this work?

$sql = "INSERT INTO table ('field') VALUES ('$value')";
$sql1 = "INSERT INTO table ('field') VALUES ('$value1')";
$sql2 = "INSERT INTO table ('field') VALUES ('$value2')";
$sql3 = "INSERT INTO table ('field') VALUES ('$value3')";

if ((mysql_query($sql, $db)) && (mysql_query($sql1, $db)) && (mysql_query($sql2, $db)) && (mysql_query($sql3, $db))) {

echo "Success";

} else {

echo "Failure";

}
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 03-04-2004, 08:02 AM   #3 (permalink)
 
True Techie

Join Date: Oct 2003

Posts: 204

gruntwerk

Default

see http://www.mysql.com/doc/en/COMMIT.html
if you use transaction safe tables this handles it for you...
gruntwerk is offline  
Old 03-04-2004, 02:22 PM   #4 (permalink)
 
Newb Techie

Join Date: Mar 2004

Posts: 10

exile

Send a message via Yahoo to exile
Talking here is the actual code

The basic code is here: http://wrjournal.net/sqlcode.php.txt
this is just the basic sql querys.

(if you goto my home page, you will see why im redesigning the site)
exile is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On