1
Bezoops
Oledrion serach option case withot results
  • 2009/1/27 19:14

  • Bezoops

  • Friend of XOOPS

  • Posts: 38

  • Since: 2004/12/9


Hi,
I'm not an expert, but I detected that: in "Search" option, in case there is not text, is published, are stock, and don't select a manufacturer, you obtain a sql sentence like this:

Quote:
SELECT b.product_id, b.product_title, b.product_submitted, b.product_submitter
FROM sn54d_oledrion_products b, sn54d_oledrion_productsmanu a
WHERE (b.product_id = a.pm_product_id ) AND b.product_cid = 0 AND GROUP BY b.product_id ORDER BY product_submitted DESC

You can see there is a AND isolate and the result is not exist products.

I resolve it changing the line 136 adding a AND like this:
Quote:
$sql2 .= ' AND (a.pm_manu_id IN ( '.implode(',', $auteurs).'))';

Is this correct?

Thanks, and excuse my bad english.

2
ghia
Re: Oledrion search option case without results
  • 2009/1/27 21:13

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In which files did you make these modifications?

3
Bezoops
Re: Oledrion search option case without results
  • 2009/1/27 21:26

  • Bezoops

  • Friend of XOOPS

  • Posts: 38

  • Since: 2004/12/9


Oops, sorry,... in oledrion/search.php

4
Bezoops
Re: Oledrion search option case without results
  • 2009/1/27 22:25

  • Bezoops

  • Friend of XOOPS

  • Posts: 38

  • Since: 2004/12/9


More oops, and in line 120-121, this is not necesary:
//} else {  
//$sql .= ' AND ';


and add in line 167: echo $sql; to see the result of the query.

5
ghia
Re: Oledrion search option case without results
  • 2009/1/28 7:41

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In what module version is this?

6
Bezoops
Re: Oledrion search option case without results
  • 2009/1/28 9:48

  • Bezoops

  • Friend of XOOPS

  • Posts: 38

  • Since: 2004/12/9


2.0 the last:https://xoops.org/modules/news/article.php?storyid=4395
Oh! a new version today, 2.1, but the file serach.php is the same:
http://xoops.instant-zero.com/modules/mydownloads/viewcat.php?cid=16

I write here because in Hervé site instant-zero there isn't a forum. Are any other place to speak about it or here is correct?

Now, in form in instant-zero I will write about this thread.
Thanks

Versions:
Xoops 2.3.2b
PHP 5.2.8

7
hervet
Re: Oledrion search option case without results
  • 2009/1/28 17:08

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


it will be corrected in a new version

8
hervet
Re: Oledrion serach option case withot results
  • 2009/1/29 9:09

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


You can replace the full script (search.php) with this :
<?php
/**
 * ****************************************************************************
 * oledrion - MODULE FOR XOOPS
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         oledrion
 * @author             Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 *
 * Version : $Id:
 * ****************************************************************************
 */

/**
 * Recherche dans les produits
 */
require 'header.php';
require_once 
OLEDRION_PATH.'class/tree.php';
$GLOBALS['current_category'] = -1;        // Pour le bloc des catégories
$xoopsOption['template_main'] = 'oledrion_search.html';
require_once 
XOOPS_ROOT_PATH.'/header.php';

$limit oledrion_utils::getModuleOption('newproducts');    // Nombre maximum d'éléments à afficher
$categories $manufacturers $vendors = array();
$baseurl OLEDRION_URL.basename(__FILE__);                // URL de ce script (sans son nom)

$xoopsTpl->assign('mod_pref'$mod_pref);                // Préférences du module


$categories $h_oledrion_cat->getAllCategories();
$vendors $h_oledrion_vendors->getAllVendors();
$manufacturers $h_oledrion_manufacturer->getItems(00'manu_name''ASC'false);


if((isset(
$_POST['op']) && $_POST['op'] == 'go') || isset($_GET['start'])) {    // Recherche des résultats
    
$xoopsTpl->assign('search_results'true);
    
$xoopsTpl->assign('global_advert'oledrion_utils::getModuleOption('advertisement'));
    
$xoopsTpl->assign('breadcrumb'oledrion_utils::breadcrumb(array(OLEDRION_URL.basename(__FILE__) => _OLEDRION_SEARCHRESULTS)));
    
oledrion_utils::setMetas(oledrion_utils::getModuleName().' - '._OLEDRION_SEARCHRESULTSoledrion_utils::getModuleName().' - '._OLEDRION_SEARCHRESULTS);

    if(!isset(
$_GET['start'])) {
        
$sql 'SELECT b.product_id, b.product_title, b.product_submitted, b.product_submitter FROM '.$xoopsDB->prefix('oledrion_products').' b, '.$xoopsDB->prefix('oledrion_productsmanu').' a WHERE (b.product_id = a.pm_product_id AND b.product_online = 1 ';
        if(
oledrion_utils::getModuleOption('show_unpublished') == 0) {    // Ne pas afficher les produits qui ne sont pas publiés
            
$sql .= ' AND b.product_submitted <= '.time();
        }
        if(
oledrion_utils::getModuleOption('nostock_display') == 0) {    // Se limiter aux seuls produits encore en stock
            
$sql .= ' AND b.product_stock > 0';
        }
        
$sql .= ') ';

        
// Recherche sur une catégorie
        
if(isset($_POST['product_category'])) {
            
$cat_cid intval($_POST['product_category']);
            if(
$cat_cid ) {
                
$sql .= 'AND (b.product_cid = '.$cat_cid.')';
            }
        }

        
// Recherche sur les fabricants
        
if(isset($_POST['product_manufacturers'])) {
            
$submittedManufacturers null;
            
$submittedManufacturers $_POST['product_manufacturers'];
            if(
is_array($submittedManufacturers) && intval($submittedManufacturers[0]) == 0) {
                
$submittedManufacturers array_shift($submittedManufacturers);
            }
            if(
is_array($submittedManufacturers) && count($submittedManufacturers) > 0) {
                
array_walk($submittedManufacturers'intval');
                
$sql .= ' AND (a.pm_manu_id IN ( '.implode(','$submittedManufacturers).'))';
            } else {
                
$submittedManufacturer intval($submittedManufacturers);
                if(
$submittedManufacturer 0) {
                    
$sql .= ' AND (a.pm_manu_id = '.$submittedManufacturer.')';
                }
            }
        }

        
// Recherche sur les vendeurs
        
if(isset($_POST['product_vendors'])) {
            
$vendor intval($_POST['product_vendors']);
            if( 
$vendor ) {
                
$sql .= ' AND (product_vendor_id = '.$vendor.')';
            }
        }

        
// Recherche sur du texte
        
if(isset($_POST['product_text']) && xoops_trim($_POST['product_text']) != '') {
            
$temp_queries $queries = array();
            
$temp_queries preg_split('/[s,]+/'$_POST['product_text']);

            foreach (
$temp_queries as $q) {
                
$q trim($q);
                
$queries[] = $myts->addSlashes($q);
            }
            if( 
count($queries) > ) {
                
$tmpObject = new oledrion_products();
                
$datas $tmpObject->getVars();
                
$fields = array();
                
$cnt 0;
                foreach(
$datas as $key => $value) {
                    if(
$value['data_type'] == XOBJ_DTYPE_TXTBOX || $value['data_type'] == XOBJ_DTYPE_TXTAREA) {
                        if(
$cnt == 0) {
                            
$fields[] = 'b.'.$key;
                        } else {
                            
$fields[] = ' OR b.'.$key;
                        }
                        
$cnt++;
                    }
                }
                
$count count($queries);
                
$cnt 0;
                
$sql .= ' AND ';
                
$searchType intval($_POST['search_type']);
                
$andor  ' OR ';
                foreach(
$queries as $oneQuery) {
                    
$sql .= '(';
                    switch(
$searchType) {
                        case 
0:        // Commence par
                            
$cond " LIKE '".$oneQuery."%' ";
                            break;
                        case 
1:        // Finit par
                            
$cond " LIKE '%".$oneQuery."' ";
                            break;
                        case 
2:        // Correspond à
                            
$cond " = '".$oneQuery."' ";
                            break;
                        case 
3:        // Contient
                            
$cond " LIKE '%".$oneQuery."%' ";
                            break;
                    }
                    
$sql .= implode($cond$fields).$cond.')';
                    
$cnt++;
                    if(
$cnt != $count) {
                        
$sql .= ' '.$andor.' ';
                    }
                }
            }
        }
        
$_SESSION['criteria_oledrion'] = serialize($sql);
    } else { 
// $_GET['start'] est en place, on a cliqué sur un chevron pour aller voir les autres pages, il faut travailler à partir des informations de la session
        
if(isset($_SESSION['criteria_oledrion'])) {
            
$sql unserialize($_SESSION['criteria_oledrion']);
        }
    }
    
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    
$sqlCount str_replace("b.product_id, b.product_title, b.product_submitted, b.product_submitter""Count(*) as cpt"$sql);
    
$result $xoopsDB->query($sqlCount);
    
$rowCount $xoopsDB->fetchArray($result);
    if(
$rowCount['cpt'] > $limit) {
        require_once 
XOOPS_ROOT_PATH.'/class/pagenav.php';
        
$pagenav = new XoopsPageNav($rowCount['cpt'], $limit $start'start');
        
$xoopsTpl->assign('pagenav'$pagenav->renderNav());
    }

    
$sql .= ' GROUP BY b.product_id ORDER BY product_submitted DESC';
    
$result $xoopsDB->query($sql$limit$start);
    
$ret = array();
    
$tempProduct $h_oledrion_products->create(true);
     while (
$myrow $xoopsDB->fetchArray($result)) {
        
$ret = array();
        
$ret['link'] = $tempProduct->getLink($myrow['product_id'], $myrow['product_title']);
        
$ret['title'] = $myts->htmlSpecialChars($myrow['product_title']);
        
$ret['href_title'] = oledrion_utils::makeHrefTitle($myts->htmlSpecialChars($myrow['product_title']));
        
$ret['time'] = $myrow['product_submitted'];
        
$ret['uid'] = $myrow['product_submitter'];
        
$xoopsTpl->append('products'$ret);
    }
    unset(
$tempProduct);
} else {
    
$xoopsTpl->assign('search_results'false);
    
$xoopsTpl->assign('global_advert'oledrion_utils::getModuleOption('advertisement'));
    
$xoopsTpl->assign('breadcrumb'oledrion_utils::breadcrumb(array(OLEDRION_URL.basename(__FILE__) => _OLEDRION_SEARCHFOR)));
    
oledrion_utils::setMetas(oledrion_utils::getModuleName().' - '._OLEDRION_SEARCHFORoledrion_utils::getModuleName().' - '._OLEDRION_SEARCHFOR);
}

require_once 
OLEDRION_PATH.'include/product_search_form.php';
$sform oledrion_utils::formMarkRequiredFields($sform);
$xoopsTpl->assign('search_form',$sform->render());

oledrion_utils::setCSS();

require_once 
XOOPS_ROOT_PATH.'/footer.php';
?>

Login

Who's Online

259 user(s) are online (149 user(s) are browsing Support Forums)


Members: 0


Guests: 259


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits