我有 2 张桌子:
agahi:(agahi_id,ostan,car_id,已发布)
user_agahi(user_agahi,ostan,tarafeagahiuser,已发布)
我使用下面的代码,但我无法检索数据
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
我使用下面的代码
<?php
defined('_JEXEC') or die();
$obj=modostanHelper::retrieve();
foreach($obj as $item)
{
$count= $item['text_agahi']+$item['text_useragahi'];
echo "<a href='' style='text-decoration:none'>".">>".$item['ostan']. " [".$count."]</a><br />";
}