0

私は2つのテーブルを持っています:

  • agahi:(agahi_id,ostan,car_id,published)

  • user_agahi(user_agahi,ostan,tarafeagahiuser,published)

以下のコードを使用していますが、データを取得できません

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


   }
4

1 に答える 1

0

$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()
于 2013-08-11T17:11:11.293 に答える