View previous topic :: View next topic |
Author |
Message |
rustybucket Smarty Regular
Joined: 28 Jan 2009 Posts: 60
|
Posted: Sun Dec 06, 2009 4:12 pm Post subject: Resource not re-compiling when db updated. |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Dec 06, 2009 4:37 pm Post subject: |
|
|
It looks like that your resource does not provide correct timestamps. Do you return timestamps and how are they generated? |
|
Back to top |
|
rustybucket Smarty Regular
Joined: 28 Jan 2009 Posts: 60
|
Posted: Sun Dec 06, 2009 5:04 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Dec 06, 2009 5:17 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Dec 06, 2009 5:30 pm Post subject: |
|
|
Another option is in PHP, sometimes that is useful:
$time = strtotime($mysqltimestamp); |
|
Back to top |
|
rustybucket Smarty Regular
Joined: 28 Jan 2009 Posts: 60
|
Posted: Sun Dec 06, 2009 6:29 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Dec 06, 2009 7:45 pm Post subject: |
|
|
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 |
|
scanreg Smarty Rookie
Joined: 12 Feb 2009 Posts: 6
|
Posted: Sun Dec 20, 2009 6:35 pm Post subject: |
|
|
I think this is exactly what I was looking for, thanks |
|
Back to top |
|
|