2014-01-22 75 views
3

有人可以告訴我這段代碼有什麼問題嗎?我只想在Joomla 2.5中獲得最後的日期。由於mysql max函數在joomla中不起作用

// 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; 

回答

5

結束不要引用功能:

$query 
    ->select('MAX('.$db->quoteName('created').')') 
    ->from($db->quoteName('#__content')); 
+0

完美的作品。非常感謝 – agustinBaraza

+0

@agustinBaraza - 請接受答案,通過點擊「打勾」圖標將問題標記爲已解決 – Lodder

0

一個;缺少在該行->from($db->quoteName('#__content'))