Skip to main content
The Nameless Site

osqdb has to be one of the worst peices of code I have seen in a while.

Tonight I was trying to convert the old custom quote system I used for #arc to qdb just for fun. I was trying to find out the code used by but came across this peice of code called OSQDB.

Here's an exerpt of code called whenever a new quote is added.

$get = mysql_query("SELECT * FROM quotes ORDER BY id DESC LIMIT 1");

while ($count = mysql_fetch_array($get)) {
 $tempid = $count["id"];
/* Increment the id */
$newid = $tempid+1;
$sql = mysql_query("INSERT INTO quotes SET id = '$newid'");
$sql = mysql_query("UPDATE quotes SET quote = '$newquote' WHERE id = '$newid'");
$sql = mysql_query("UPDATE quotes SET comment = '$comment' WHERE id = '$newid'");
$sql = mysql_query("UPDATE quotes SET ip = '$ip' WHERE id = '$newid'");
  1. It loops through 1 entry trying to find the latest entry number (I'm sure max() is faster than order by and limit).
  2. Once its it found, it does one insert with the id being set. Then it does 3 more queries setting each field in its own query.

That sorta explains why the db doesn't have auto_increment fields turned on, but its scary. I'm afraid of looking at much more of the code. Luckily I then found Rash Quote Management System. I don't like this one very much either.. but they are more personal reasons versus code issues.

I should clean up and submit patches (it doesn't seem to have been updated since 2006) for rqms.