refuses to complete all queries

refuses to complete all queries

am 10.12.2009 01:18:05 von Allen McCabe

--001636e1f972bd7343047a54bd64
Content-Type: text/plain; charset=ISO-8859-1

I have a "PURGE ORDERS" link that calculates which orders are made up
entirely of expired shows and deletes them. Well, that's idea anyhow.

The procedure does 3 things:

1. Gets the order_id of all orders that contain all expired shows
2. Deallocates the quantity of the seats on each show from the show table
(freeing up 'inventory')
3. Deletes the order from the order table and all associated entries on the
line_item table.

Well, it does the first step beautifully, but does not want to delete the
table entries. The problem seems to be somewhere in:


// CREATE STRING FROM $black_list[] array
$expired_order_ids_str = implode($black_list, ', ');

// UPDATE SHOW QUANTITIES - SUBTRACT SEATS
$getshowsSQL = "SELECT * FROM afy_order_lineitem WHERE order_id IN
({$expired_order_ids_str})";
$showsResult = mysql_query($getshowsSQL);
while ($updateShow = mysql_fetch_array($showsResult))
{
$updatequantitySQL = "UPDATE afy_show SET show_seats_reqd =
(show_seats_reqd - {$updateShow['quantity']}) WHERE show_id =
{$updateShow['show_id']}";
$updatequantityResult = mysql_query($updatequantitySQL);
}
mysql_free_result($showsResult);

// UPDATE MYSQL
$deleteSQL = "DELETE FROM afy_order WHERE order_id IN
({$expired_order_ids_str})";
mysql_query($deleteSQL);
$deleteSQL = "DELETE FROM afy_order_lineitem WHERE order_id IN
({$expired_order_ids_str})";
$deleteResult = mysql_query($deleteSQL);
if ($deleteResult)
{
$message = "Orders successfully Purged! />(Order #'s deleted: {$expired_order_ids_str})";
}
break;

The works just fine, up until the // UPDATE MYSQL line. I am NOT getting the
$message set, and the orders are NOT being deleted. Only the afy_show gets
updated. Can anyone see an problem with this??

Thanks!

--001636e1f972bd7343047a54bd64--

Re: refuses to complete all queries

am 10.12.2009 02:34:57 von Phpster

On Wed, Dec 9, 2009 at 7:18 PM, Allen McCabe wrote:
> I have a "PURGE ORDERS" link that calculates which orders are made up
> entirely of expired shows and deletes them. Well, that's idea anyhow.
>
> The procedure does 3 things:
>
> 1. Gets the order_id of all orders that contain all expired shows
> 2. Deallocates the quantity of the seats on each show from the show table
> (freeing up 'inventory')
> 3. Deletes the order from the order table and all associated entries on t=
he
> line_item table.
>
> Well, it does the first step beautifully, but does not want to delete the
> table entries. The problem seems to be somewhere in:
>
>
> // CREATE STRING FROM $black_list[] array
> =A0$expired_order_ids_str =3D implode($black_list, ', ');
>
> =A0// UPDATE SHOW QUANTITIES - SUBTRACT SEATS
> =A0$getshowsSQL =3D "SELECT * FROM afy_order_lineitem WHERE order_id IN
> ({$expired_order_ids_str})";
> =A0$showsResult =3D mysql_query($getshowsSQL);
> =A0while ($updateShow =3D mysql_fetch_array($showsResult))
> =A0{
> =A0 $updatequantitySQL =3D "UPDATE afy_show SET show_seats_reqd =3D
> (show_seats_reqd - {$updateShow['quantity']}) WHERE show_id =3D
> {$updateShow['show_id']}";
> =A0 $updatequantityResult =3D mysql_query($updatequantitySQL);
> =A0}
> =A0mysql_free_result($showsResult);
>
> =A0// UPDATE MYSQL
> =A0$deleteSQL =3D "DELETE FROM afy_order WHERE order_id IN
> ({$expired_order_ids_str})";
> =A0mysql_query($deleteSQL);
> =A0$deleteSQL =3D "DELETE FROM afy_order_lineitem WHERE order_id IN
> ({$expired_order_ids_str})";
> =A0$deleteResult =3D mysql_query($deleteSQL);
> =A0if ($deleteResult)
> =A0{
> =A0 $message =3D "Orders successfully Purged! r
> />(Order #'s deleted: {$expired_order_ids_str})
";
> =A0}
> =A0break;
>
> The works just fine, up until the // UPDATE MYSQL line. I am NOT getting =
the
> $message set, and the orders are NOT being deleted. Only the afy_show get=
s
> updated. Can anyone see an problem with this??
>
> Thanks!
>

If you echo out the statement and run it thru phpmyadmin or some other
db tool, does the statement work?

--=20

Bastien

Cat, the other other white meat

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