Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql max function does not work in joomla

Tags:

mysql

max

joomla

someone can tell me what is wrong in this code? I just want to get the last date in Joomla 2.5. Thanks

    // Get a db connection.
    $db = JFactory::getDbo();

    // Create a new query object.
    $query = $db->getQuery(true);

    $query
    ->select($db->quoteName('MAX(created)'))
    ->from($db->quoteName('#__content'))


    $db->setQuery($query);
    $result = $db->loadResult();

    return $result;
like image 226
agustinBaraza Avatar asked Feb 14 '26 09:02

agustinBaraza


1 Answers

don't quote functions:

$query
    ->select('MAX('.$db->quoteName('created').')')
    ->from($db->quoteName('#__content'));
like image 181
Riccardo Zorn Avatar answered Feb 16 '26 00:02

Riccardo Zorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!