Zen Cart Logo
Forums / General Questions / getting a timestamp from an database insert/update when there is no timestamp field

getting a timestamp from an database insert/update when there is no timestamp field

Views: 652

Results 1 to 3 of 3
8 Jan 2013, 10:00 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

getting a timestamp from an database insert/update when there is no timestamp field

I'm investigating an anomaly regarding two addresses in the address_book table. As part of that it would be most useful to know when exactly the two addresses were inserted/new records created.
Is that information possible to extract from the database, given that this table has no timestamp column, or is there any other concurrent db activity action to this insert that may give me such information?

9 Jan 2013, 12:13 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: getting a timestamp from an database insert/update when there is no timestamp field

torvista:

I'm investigating an anomaly regarding two addresses in the address_book table. As part of that it would be most useful to know when exactly the two addresses were inserted/new records created.
Is that information possible to extract from the database, given that this table has no timestamp column,

To the best of my knowledge, without a timestamp column there is no way to know when exactly when the records were added.

torvista:

or is there any other concurrent db activity action to this insert that may give me such information?

If you have the MySQL logging and/or replication enabled you may be able to find the info from there. Otherwise the only other thing you may find useful is to compare the address_book_id numbers as this will let you know the order that the address were added, which may or may not be useful.

Cheers
Rod

9 Jan 2013, 2:20 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,874
Plugin Contributions:
7

Re: getting a timestamp from an database insert/update when there is no timestamp field

Thanks, as I thought.
So, moving on and trying to add a last_updated timestamp field to the address_book table, I was not having any success in integrating it into the current sql in header.php in address_book_process.
The problem was the 'type' as anything apart from 'noquotestring' (like 'string' or 'date') produced no result.
So just for the record/Google this is how I added a timestamp to a sql query.

Original

$sql_data_array= array(array('fieldName'=>'entry_firstname', 'value'=>$firstname, 'type'=>'string'),
                           array('fieldName'=>'entry_lastname', 'value'=>$lastname, 'type'=>'string'),
                           array('fieldName'=>'entry_telephone','value'=>$telephone, 'type'=>'string'),
                           array('fieldName'=>'entry_street_address', 'value'=>$street_address, 'type'=>'string'),
                           array('fieldName'=>'entry_postcode', 'value'=>$postcode, 'type'=>'string'),
                           array('fieldName'=>'entry_city', 'value'=>$city, 'type'=>'string'),
                           array('fieldName'=>'entry_country_id', 'value'=>$country, 'type'=>'integer'),
                           );

Modified
The db field is defined as datetime.

$sql_data_array= array(array('fieldName'=>'entry_firstname', 'value'=>$firstname, 'type'=>'string'),
                           array('fieldName'=>'entry_lastname', 'value'=>$lastname, 'type'=>'string'),
                           array('fieldName'=>'entry_telephone','value'=>$telephone, 'type'=>'string'),
                           array('fieldName'=>'entry_street_address', 'value'=>$street_address, 'type'=>'string'),
                           array('fieldName'=>'entry_postcode', 'value'=>$postcode, 'type'=>'string'),
                           array('fieldName'=>'entry_city', 'value'=>$city, 'type'=>'string'),
                           array('fieldName'=>'entry_country_id', 'value'=>$country, 'type'=>'integer'),
                           array('fieldName'=>'last_updated', 'value'=>'now()', 'type'=>'nostringquote')
                           );