|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ShamusMay Smarty Rookie
Joined: 28 Apr 2015 Posts: 18
|
Posted: Fri Jan 29, 2016 2:51 pm Post subject: Count rows in array where 2 fields are gt or lt $smarty.now |
|
|
I have an array of data with fields start_date and end_date
I want to get a count of only the rows where the start_date is gt $smarty.now and end_date is lt $smarty.now.
I know I can get the entire array count with {$Array|@count} , but how can I add the condition to limit it to only rows within the criteria above?
Thanks for any help. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jan 29, 2016 3:16 pm Post subject: |
|
|
You can get that information from the database, where these rows came from, with a single additional query, and then pass it to Smarty. |
|
Back to top |
|
ShamusMay Smarty Rookie
Joined: 28 Apr 2015 Posts: 18
|
Posted: Fri Jan 29, 2016 3:23 pm Post subject: |
|
|
Just thought I could use info already passed to smarty and use an if condition instead of another db call. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jan 29, 2016 5:21 pm Post subject: |
|
|
Could? Certainly.
Will it be worth the time spent?
No. |
|
Back to top |
|
ShamusMay Smarty Rookie
Joined: 28 Apr 2015 Posts: 18
|
Posted: Fri Jan 29, 2016 6:39 pm Post subject: |
|
|
Done, thanks for the direction. |
|
Back to top |
|
|
|
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
|