Hi there,
i want to ask you how can i use MAX() function when we use GROUP BY in DBUtil?
for example did you see News_userapi_getMonthsWithNews() function?
there we have something like this:
$order = "GROUP BY EXTRACT(YEAR_MONTH FROM $news_column[from]) ORDER BY $news_column[from] DESC";
$date = DateUtil::getsysDatetime();
$where = "($news_column[from] < '$date' AND $news_column[published_status] = '0')";
$dates = DBUtil::selectFieldArray('news', 'from', $where, $order);
in this case, i want to know how can i select MAX(from)?
i need to select 2011-07-20 between 2011-07-18 and 2011-07-19 and 2011-07-20.
thank you
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- rgasch created topic »Using PageUtil::addVar() to load script code« 11:48 AM
- michiel responded to »password problem« 10:01 AM
- mazdev responded to »Hide "Register new account" and change template to 3 col« 07:50 AM
- mesteele101 created topic »Zikula 1.3.3 - Site Search 1.5.2 - Unable to turn off plug-ins« 07:48 AM
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
MAX() function in DBUtil
-
- Rank: Registered User
- Registered: Dec 02, 2007
- Last visit: Oct 21, 2009
- Posts: 40
-
- Rank: Team Member
- Registered: Jan 05, 2003
- Last visit: May 28, 2010
- Posts: 776
Hi,
for this you need to manually execute SQL and pass a column array (ie: the names of the columns of your result). Something like this:
Code
$sql = 'SELECT blah blah blah ... ';
$columns = array('maxvalue');
$res = DBUtil::executeSQL ($sql);
$counts = DBUtil::marshallObjects ($res, $columns);
Greetings
Robert
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
