Hi:

I had just wanted to make sure that I wasn't crazy and my understanding of how MySQL (5.0.25 is my version) works was not flawed. It seems from the responses here that I've got the column declared properly, at least.

I originally asked the question because I have a different table, with basically the exact same setup. (The data titles, and editions, of software products, in this case the editions mean versions of a title on a different platform. so the "title" might be "Photoshop" and the edition would be "Windows, Mac, etc.".)

What is odd is that the title table's timestamp is auto-updating whenever a title is modified, and the editions table isn't. Both tables have only one timestamp column and the structure is very similar.

This is from the title table:

`ttl_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

This is from the edition table:

`edi_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

I'm checking out my code now to see if there's a difference in the editions update form vs. the titles update form, but both forms run through the same framework.

Very odd...perhaps just an idiotic mistake of mine somewhere.


Cheers,

Marc






Le 2 juil. 08 à 18:01, bzcoder a écrit :

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

_______________________________________________
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