php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2142 MySQL/Php3? Odd increments in database
Submitted: 1999-08-25 05:17 UTC Modified: 2000-07-03 19:32 UTC
From: matt at insnet dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.10 OS: Solaris 2.6
Private report: No CVE-ID: None
 [1999-08-25 05:17 UTC] matt at insnet dot net
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-03 19:32 UTC] rasmus at cvs dot php dot net
This report doesn't contain anything that points to a bug
in PHP.  If you still have the problem, try to simplify
your code to the point where you can pin it down to a specific 
PHP function not working the way you expect.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jun 01 17:01:27 2025 UTC