Subject | Re: [firebird-php] Re: firebase15 |
---|---|
Author | Lester Caine |
Post date | 2004-05-25T09:25:54Z |
dleec45 wrote:
Just replace the locks with 'proper database stuff'
drop this
$DB->BeginTrans();
$newID = GenID('gen_name');
$DB->CommitTrans();
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
Just replace the locks with 'proper database stuff'
drop this
> // Lock Tableuse
> $Query = "LOCK TABLES credit WRITE";
$DB->BeginTrans();
$newID = GenID('gen_name');
> ... some processing....Get Count from the query.
>
> $Query = "SELECT COUNT(ID) " .
> "FROM credit " .
> "WHERE ExternalID = '$externalID' ";
> ... some processing....
>
> list($count) = mysql_fetch_row($DatabaseResult);
> ... some processing....Add the generator value into the query
> $Query = "INSERT INTO credit " .ID
> "(ExternalID, Purchaser, Purchased, " .newID
> "Expires, InitialValue, RemainingValue) VALUES (" .
> "'$externalID', " .drop this
> "$purchaser," .
> "NOW(), " .
> "DATE_ADD(NOW(), INTERVAL 1 YEAR), " .
> "$value, " .
> "$value)";
> if(!($DatabaseResult = $db->Execute($Query)))
> ... some processing....
>
> $newID = mysql_insert_id($DatabaseLink);use
> // And FINALLY, unlock table
> $Query = "UNLOCK TABLES";
$DB->CommitTrans();
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services