Как обединить запросы?

Тема в разделе "Joomla и SEF (ЧПУ)", создана пользователем Raptor, 07.05.2008.

  1. Offline

    Raptor Гость

    как и полагается, монстро-SEF генерит кучу запросов.
    подскажите плиз чего написать чтоб одним запросом вытянуть сразу несколько данных.

    пример:
    собсо вот что имеем:

    Код (CODE):
    1. 45: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='1' AND jos_vm_category.category_id='1'
    2. 46: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='2' AND jos_vm_category.category_id='2'
    3. 47: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='3' AND jos_vm_category.category_id='3'
    4. 48: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='4' AND jos_vm_category.category_id='4'
    5. 49: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='5' AND jos_vm_category.category_id='5'
    6. 50: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='14' AND jos_vm_category.category_id='14'
    7. 51: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='34' AND jos_vm_category.category_id='34'
    8. 52: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='32' AND jos_vm_category.category_id='32'
    9. 53: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='1' AND jos_vm_category.category_id='1'
    10. 54: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='33' AND jos_vm_category.category_id='33'
    11. 55: SELECT category_id, category_name,category_parent_id FROM jos_vm_category, jos_vm_category_xref WHERE jos_vm_category_xref.category_child_id='2' AND jos_vm_category.category_id='2'


    вот код, который нужно поправить:

    Код (CODE):
    1. function create_category_path($category_id) {
    2.     global $database;
    3.  
    4.     $vmsefpath = '';
    5.     do {
    6.         $q = "SELECT category_id, category_name,category_parent_id FROM #__".VM_TABLEPREFIX."_category, #__".VM_TABLEPREFIX."_category_xref WHERE ";
    7.         $q .= "#__".VM_TABLEPREFIX."_category_xref.category_child_id='$category_id' ";
    8.         $q .= "AND #__".VM_TABLEPREFIX."_category.category_id='$category_id'";
    9.         $database->setQuery($q);
    10.         $database->loadObject($row);
    11.         if ($row->category_parent_id) {
    12.             $link = sefencode($row->category_name);
    13.             $vmsefpath = '/'. $link. $vmsefpath;
    14.         } else {
    15.             $link = sefencode($row->category_name);
    16.             $vmsefpath = $link . $vmsefpath;
    17.         }
    18.         $category_id = $row->category_parent_id;
    19.     } while ($row->category_parent_id<>0);
    20.  
    21.     return $vmsefpath;
    22. }


    как написать, чтоб одним запросов вытянуть сразу все эти id.
     
    Последнее редактирование модератором: 07.05.2008
  2.  

Поделиться этой страницей

Загрузка...