[PHP-DEV] Multiple inserts in one sybase_query issue From: Ben Gabrielson (benjamin <email protected>)
Date: 06/18/01

I'm running PHP 3 (and PHP 4 on another server) with Sybase 11.9.2 on the
database server.

I have tried in a number or variations to insert a series of updates and
inserts in the same sybase_query. I build a $query consisting of around
15-20 inserts and updates and call the sybase_query function, everything
works fine and it writes to the database as expected however none of the
sybase_querys after this point are recorded.

For example when I create this string:

$query = "Declare  <email protected> numeric(10,0)\n";
$query .= "Insert into nonuser_signup (email, firstname, lastname, gender)
values ('$email', '$firstname', '$lastname', '$gender')\n";
$query .= "Select  <email protected> = @ <email protected>\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Free_Stuff, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Contests, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Surveys, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Shopping, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Games, 5,
getdate())\n";
$query .= "Insert into user_optin (user_id,optin_type_id,promotion_id)
values ($user_id, 10, 5)\n";
$result = sybase_query($query, $db);

Everything works fine, however when its broken up like this:

$query = "Declare  <email protected> numeric(10,0)\n";
$query .= "Insert into nonuser_signup (email, firstname, lastname, gender)
values ('$email', '$firstname', '$lastname', '$gender')\n";
$query .= "Select  <email protected> = @ <email protected>\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Free_Stuff, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Contests, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Surveys, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Shopping, 5,
getdate())\n";
$query .= "Insert into nonuser_optin (nonuser_signup_id, optin_type_id,
promotion_id, signup_date) values ( <email protected>, $Games, 5,
getdate())\n";
$result = sybase_query($query, $db);
$query = '';
$query .= "Insert into user_optin (user_id,optin_type_id,promotion_id)
values ($user_id, 10, 5)\n";
$result = sybase_query($query, $db);

The last insert doesn't work. Is this a bug in PHP or am I overlooking
something? Logically it seems that it should function the same in both
cases.

I should also note that when I break that up into a series of completely
independant queries it works fine too, I can run a series of single inserts
each with their own sybase_query and they all insert fine.

However as you can see in the case above I am using a @ <email protected> which makes
splitting these up into different queries impossible.

Thnaks in advance for any aid.

Ben

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>