Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Resource not re-compiling when db updated.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
rustybucket
Smarty Regular


Joined: 28 Jan 2009
Posts: 60

PostPosted: Sun Dec 06, 2009 4:12 pm    Post subject: Resource not re-compiling when db updated. Reply with quote

I have a resource that pulls some html from a mysql database and populates smarty vars inside of it (like using a normal template). All is working fine EXCEPT....

If I change the entry in the database, the script is still returning the old version of it. If I go the templates_c and delete the compiled versions and re-run the script it returns the newest version from the db.

The only thing I'm using this resource for is an email template library and it's use will be minimal. So if I could just turn off compiling for this one resource I would be fine.

Is there any way to turn off the templates_c or force compile on every invocation?

Thanks in advance for any guidance or assistance you may be able to provide.

Rusty
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Dec 06, 2009 4:37 pm    Post subject: Reply with quote

It looks like that your resource does not provide correct timestamps. Do you return timestamps and how are they generated?
Back to top
View user's profile Send private message
rustybucket
Smarty Regular


Joined: 28 Jan 2009
Posts: 60

PostPosted: Sun Dec 06, 2009 5:04 pm    Post subject: Reply with quote

Could definitely be a possibility.

My timestamp format is as such: 2009-12-06 09:39:53

It appears to be updating in the database correctly (ie, when I update an email template the timestamp becomes current.)

My timestamp is stored in mysql as a 'timestamp' data type and the default is 'CURRENT_TIMESTAMP'
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Dec 06, 2009 5:17 pm    Post subject: Reply with quote

Smarty does require a unix time stamp. You must convert the MSQL timestamps like this:

Code:
select UNIX_TIMESTAMP(your time stamp field) from....
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Dec 06, 2009 5:30 pm    Post subject: Reply with quote

Another option is in PHP, sometimes that is useful:

$time = strtotime($mysqltimestamp);
Back to top
View user's profile Send private message Visit poster's website
rustybucket
Smarty Regular


Joined: 28 Jan 2009
Posts: 60

PostPosted: Sun Dec 06, 2009 6:29 pm    Post subject: Reply with quote

Wow! Can't thank you guys enough!!

For an immediate fix I just used the php function. For a long term fix I need to alter my script to insert the unix stamp into the db.

Thanks again!! Much appreciated!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Dec 06, 2009 7:45 pm    Post subject: Reply with quote

As Uwe pointed out, MySQL can convert the mysql timestamp datatype right in the select statement, in case you want to leave the db setup alone.

select *,UNIX_TIMESTAMP(created_at) as mytime from ...
Back to top
View user's profile Send private message Visit poster's website
scanreg
Smarty Rookie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Sun Dec 20, 2009 6:35 pm    Post subject: Reply with quote

I think this is exactly what I was looking for, thanks Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP