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

Count rows in array where 2 fields are gt or lt $smarty.now

 
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
ShamusMay
Smarty Rookie


Joined: 28 Apr 2015
Posts: 18

PostPosted: Fri Jan 29, 2016 2:51 pm    Post subject: Count rows in array where 2 fields are gt or lt $smarty.now Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jan 29, 2016 3:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
ShamusMay
Smarty Rookie


Joined: 28 Apr 2015
Posts: 18

PostPosted: Fri Jan 29, 2016 3:23 pm    Post subject: Reply with quote

Just thought I could use info already passed to smarty and use an if condition instead of another db call.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jan 29, 2016 5:21 pm    Post subject: Reply with quote

Could? Certainly.
Will it be worth the time spent?
No.
Back to top
View user's profile Send private message
ShamusMay
Smarty Rookie


Joined: 28 Apr 2015
Posts: 18

PostPosted: Fri Jan 29, 2016 6:39 pm    Post subject: Reply with quote

Done, thanks for the direction.
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