Fork me on GitHub

MAX() function in DBUtil  Bottom

  • 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
  • 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
  • 0 users

This list is based on users active over the last 60 minutes.