在joomla程序中,我使用以下代码从数据库表中请求两列:
$db=JFactory::getDbo();
$query=$db->getQuery(true);
$query->select($db->quoteName(array('keywords','en_GB_tips')))
->from('#__tooltip_explain');
$db->setQuery($query);
$keywords=$db->loadColumn(0);
$tips=$db->loadColumn(1);
此代码曾用于工作,但最近最后一个命令:loadColumn(1)返回空。我尝试了多个版本,但基本上如果我请求超过1列/行,只有第一个包含数据。我的服务器是一个运行最新php和mysql 5.6的apache2实例。我还尝试了另一台运行apache2的服务器,但是使用mariadb作为数据库,它也没有在那里工作。但是,我使用mysql 5.5在旧服务器上运行。
有没有人知道为什么这适用于mysql 5.5而不是另一个数据库? (我不拥有mysql 5.6的服务器,所以我不能确定最近是否从5.5更新到5.6)
答案 0 :(得分:1)
试试这个,
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('keywords','en_GB_tips')))
->from('#__tooltip_explain');
$db->setQuery($query);
$results = $db->loadObject();//if more than one row then loadObjectList()
$keywords = $results->keywords;
$tips = $results->en_GB_tips;
可以找到Joomla文档here