Subject Re: [firebird-php] Re: firebase15
Author Lester Caine
dleec45 wrote:

Just replace the locks with 'proper database stuff'

drop this
> // Lock Table
> $Query = "LOCK TABLES credit WRITE";

use
$DB->BeginTrans();
$newID = GenID('gen_name');

> ... some processing....
>
> $Query = "SELECT COUNT(ID) " .
> "FROM credit " .
> "WHERE ExternalID = '$externalID' ";
> ... some processing....
>
> list($count) = mysql_fetch_row($DatabaseResult);
Get Count from the query.

> ... some processing....

Add the generator value into the query

> $Query = "INSERT INTO credit " .
ID
> "(ExternalID, Purchaser, Purchased, " .
> "Expires, InitialValue, RemainingValue) VALUES (" .
newID
> "'$externalID', " .
> "$purchaser," .
> "NOW(), " .
> "DATE_ADD(NOW(), INTERVAL 1 YEAR), " .
> "$value, " .
> "$value)";
> if(!($DatabaseResult = $db->Execute($Query)))
> ... some processing....
>
drop this
> $newID = mysql_insert_id($DatabaseLink);
> // And FINALLY, unlock table
> $Query = "UNLOCK TABLES";

use
$DB->CommitTrans();

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services