chestertb
10-07-2006, 05:51 PM
Hi All,
I just want to make sure I have the correct syntax here.
The following snippet checks the accounts and makes sure that ledgers exists for the current month. If not, it will create them.
The idea is that the first transaction in any month will trigger the creation of the ledgers, so to do that, I need to read lock the ledger table so that any attempt to read the ledger table will be blocked until the function is complete.
Like this...
$accmth = $dx[0]."-".$dx[1];
$qrl = mysql_query("LOCK TABLE ledger READ");
$qrm = "SELECT * FROM ledger WHERE PLmonth = '$accmth'";
$rsm = mysql_query($qrm, $link);
$nrm = mysql_num_rows($rsm);
if($nrm==0)
{
//make the new ledgers here
}
$qrl = mysql_query("UNLOCK TABLES");
I know this is simple, but because this is a critical function, and it might not return errors even though it might not do exactly what I want, I thought I'd ask people who know more than me.
Thanks
CTB
I just want to make sure I have the correct syntax here.
The following snippet checks the accounts and makes sure that ledgers exists for the current month. If not, it will create them.
The idea is that the first transaction in any month will trigger the creation of the ledgers, so to do that, I need to read lock the ledger table so that any attempt to read the ledger table will be blocked until the function is complete.
Like this...
$accmth = $dx[0]."-".$dx[1];
$qrl = mysql_query("LOCK TABLE ledger READ");
$qrm = "SELECT * FROM ledger WHERE PLmonth = '$accmth'";
$rsm = mysql_query($qrm, $link);
$nrm = mysql_num_rows($rsm);
if($nrm==0)
{
//make the new ledgers here
}
$qrl = mysql_query("UNLOCK TABLES");
I know this is simple, but because this is a critical function, and it might not return errors even though it might not do exactly what I want, I thought I'd ask people who know more than me.
Thanks
CTB