Marc Antony Vose wrote:
Hi there.

I exported this create table statement from an existing table of mine. I was just wondering if someone would enlighten me as to why my "edi_updated" timestamp column is not auto-updating when a record is updated?

Well, my guess would be because your code tells it not to. For example, if your using some nice object oriented code, where you do something like:
-----
// set some edition id value
$ediid = 123;

// load the edition data
$myedi = new editionClass($ediid);

// set a 20% discount - ideally this data should actually
// have come from someone, ie entered on a form perhaps
// by the user
$discount = .80;
$newprice = $myedi->getField('edi_price') * $discount;

// update the price of the edition
$myedi->setField('edi_price', $newprice);

// update the record
$myedi->update();
----

or if you prefer a condensed coding style:
------
// get the edition
$myedi->new editionClass($ediid);
//set the discount, ideally this is provided by a user instead
// of hardcoded
$discount=.80;
// make our changes and update the record
$myedi->setDiscount($discount)->updateRecord();
------

The above generates a long update clause such as:
UPDATE EDITIONS
SET EDI_TITLE='$this->edi_title',
...
EDI_UPDATED=$this->edi_updated,
...
WHERE EDI_ID = $this->edi_id

(though of course, your using the safer syntax where you bind the variables instead of writing it out directly - it's just easier to write this way)

In which case, since your code explicitly specified what the update timestamp should be(and since you did not change the value, it is the original timestamp) the field will not be updated.

Just a guess though, since I don't have your code here. :-)

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to