如何在joomla查询中使用mysql变量

时间:2019-01-10 22:38:36

标签: mysql joomla3.0

如何在Joomla中使用mysql变量!查询生成器并使用loadObjectList()

1 个答案:

答案 0 :(得分:0)

非常简单

$query = $db->getQuery(true);
$query->select('apses.*,'
        . ' @sess_total_uptime := TIMESTAMPDIFF(MINUTE, apses_date_created, apses_last_activity) as sess_total_uptime, '
        . ' FLOOR(@sess_total_uptime / 60) as hours, '
        . ' ROUND(MOD(@sess_total_uptime, 60)) as mins '
);
$query->from($db->quoteName('#__mysessions', 'apses'));
$db->setQuery($query);
$db->execute(); // <-- This thing is *VERY* IMP
$rows = $db->loadObjectList();