Bug #2142: MySQL/Php3? Odd increments in database

From: Date: Wed, 25 Aug 1999 09:17:56 +0000
Subject: Bug #2142: MySQL/Php3? Odd increments in database
Groups: php.dev 
Request: Send a blank email to php-dev+get-10165@lists.php.net to get a copy of this message
From: matt@insnet.net Operating system: Solaris 2.6 PHP version: 3.0.10 PHP Bug Type: MySQL related Bug description: MySQL/Php3? Odd increments in database Hi, I have configured php3 as an apache module (as in the documentation). I am using a modified version of stonekeep's Keystone system. We have modified the database and use a date-based counter that stores ticket id's as yyyymmddn. n increments for each new ticket and rollsover at midnight. I have written some code to handle this and this was working fine, until monday. Now I get odd increments in the database, i.e. 'n' skips. It's as if the increment part of the code is being run although no tickets match the 'missing' numbers. Here is my code: if($db_result[lastdate_value]==$long_date) { db_query("update laststate set last_ticketid=last_ticketid+1"); LogIt("INFO","postslip.php3","Old ticket vars: $db_result[lastdate_value] $db_result[last_ticketid]"); } else { db_query("update laststate set last_ticketid=$default_stateval"); db_query("update laststate set lastdate_value=$long_date"); } The mysql database stores the last values in a table as follows: # mysqlshow flash laststate Database: flash Table: laststate Rows: 1 +----------------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+------------+------+-----+---------+-------+ | lastdate_value | int(16) | YES | | | | | last_ticketid | bigint(11) | YES | | | | +----------------+------------+------+-----+---------+-------+ I use bigint as I was getting a rollover with 'int'. Then a piece of code 'assembles' the date and the new incremented last_ticketid value, as follows: #ok, now query the db for the new human ticket id just created above... $newdb_query = db_query("select * from laststate"); $newdb_result = db_fetch_array($newdb_query); $human=$newdb_result[lastdate_value].$newdb_result[last_ticketid]; This $human variable is then inserted into the slips table in a custom, bigint field called 'human_sid'. Any help on this issue would be a great help! Regards, Matt Duggan, mailto:matt@insnet.net

« previous php.dev (#10165) next »