从joomla 2.5中的数据库检索数据
我有两张桌子:从joomla 2.5中的数据库检索数据,joomla,Joomla,我有两张桌子: agahi:(agahi_id,ostan,car_id,published) 用户_agahi(用户_agahi,奥斯坦,塔拉菲阿加希用户,已发布) 我使用下面的代码,但我无法检索数据 class modostanHelper { public function retrieve() { $db=JFactory::getDBo(); $sql="create view agahi
- agahi:(agahi_id,ostan,car_id,published)
- 用户_agahi(用户_agahi,奥斯坦,塔拉菲阿加希用户,已发布)
class modostanHelper
{
public function retrieve()
{
$db=JFactory::getDBo();
$sql="create view agahi as(select ostan,count(id_useragahi) as text_agahi from #__npco_useragahi where published=1 group by ostan) ";
$db->setQuery($sql);
$db=JFactory::getDBo();
$sql_1="create view useragahi AS (select ostan,count(id_agahi) as text_useragahi from #__npco_agahi where published=1 group by ostan) ";
$db->setQuery($sql_1);
$db=JFactory::getDBo();
$sql_2="select * from agahi,useragahi where agahi.ostan=useragahi.ostan";
$db->setQuery($sql_2);
return $db->loadAssocList();
}
}
在文件default.php
中,我使用下面的代码
之后
$db=JFactory::getDBo();
$sql="create view agahi as(select ostan,count(id_useragahi) as text_agahi from #__npco_useragahi where published=1 group by ostan) ";
$db->setQuery($sql);
执行查询:
$db->query()