[Solar-talk] updated not being updated

Paul M Jones pmjones at solarphp.com
Fri Aug 4 12:16:32 PDT 2006


On Aug 4, 2006, at 8:29 AM, Jeff Surgeson wrote:

> Is it my imagination or has something changed with regards the  
> updated field
> being automaticly updated on a mysql save()
>
> Looking at Solar_Sql_Table save() is a wrapper for insert and  
> update, on
> insert updated & created are done ok but on update the updated  
> field is no
> longer updated with timestamp.
>
> In the update function it has:
>
> // set the "updated" timestamp
> if (empty($data['updated'])) {
> 	$data['updated'] = date('Y-m-d\TH:i:s');
> }
>
> If I remove the if statement and force the update all works ok on  
> update.

I don't think I changed anything, other than going to Solar_Struct  
instead of using an array for row returns.  That might have been enough.

Regardless, the reason for the behavior is that $data->updated  
already has a value; i.e., the value from the previous "updated" date- 
time.

Per your example, I have removed the if() and now forcibly reset the  
"updated" value in my working copy.  Will commit to SVN.

Good catch, thanks!


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>




More information about the solar-talk mailing list