| @@ 619-645 (lines=27) @@ | ||
| 616 | * @param $filter_arr |
|
| 617 | * @return int|void |
|
| 618 | */ |
|
| 619 | function mod_search_count($queryarray, $andor, $limit, $offset = 0, $filter_arr) |
|
| 620 | { |
|
| 621 | global $xoopsDB, $eh; |
|
| 622 | $count = 0; |
|
| 623 | ||
| 624 | $sql = 'SELECT COUNT(DISTINCT i.itemid) FROM ' |
|
| 625 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') |
|
| 626 | . ' d, ' |
|
| 627 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') |
|
| 628 | . ' i LEFT JOIN ' |
|
| 629 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text') |
|
| 630 | . " t ON (i.itemid=t.itemid) WHERE d.itemid=i.itemid AND i.status='2'"; |
|
| 631 | // because count() returns 1 even if a supplied variable |
|
| 632 | // is not an array, we must check if $queryarray is really an array |
|
| 633 | if (is_array($queryarray) && $count = count($queryarray)) { |
|
| 634 | $sql .= " AND ((d.value LIKE '%$queryarray[0]%' OR i.title LIKE '%$queryarray[0]%' OR t.description LIKE '%$queryarray[0]%')"; |
|
| 635 | for ($i = 1; $i < $count; ++$i) { |
|
| 636 | $sql .= " $andor "; |
|
| 637 | $sql .= "(d.value LIKE '%$queryarray[$i]%' OR i.title LIKE '%$queryarray[$i]%' OR t.description LIKE '%$queryarray[$i]%')"; |
|
| 638 | } |
|
| 639 | $sql .= ') '; |
|
| 640 | } |
|
| 641 | $result = $xoopsDB->query($sql) or $eh->show('0013'); |
|
| 642 | list($count) = $xoopsDB->fetchRow($result); |
|
| 643 | ||
| 644 | return $count; |
|
| 645 | } |
|
| 646 | ||
| 647 | /** |
|
| 648 | * @param int $dtypeid |
|
| @@ 186-211 (lines=26) @@ | ||
| 183 | * @param int $offset |
|
| 184 | * @return int|void |
|
| 185 | */ |
|
| 186 | function mod_search_count($queryarray, $andor, $limit, $offset = 0) |
|
| 187 | { |
|
| 188 | global $xoopsDB, $eh; |
|
| 189 | $count = 0; |
|
| 190 | $sql = 'SELECT COUNT(DISTINCT i.itemid) FROM ' |
|
| 191 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') |
|
| 192 | . ' d, ' |
|
| 193 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') |
|
| 194 | . ' i LEFT JOIN ' |
|
| 195 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text') |
|
| 196 | . " t ON (i.itemid=t.itemid) WHERE d.itemid=i.itemid AND i.status='2'"; |
|
| 197 | // because count() returns 1 even if a supplied variable |
|
| 198 | // is not an array, we must check if $queryarray is really an array |
|
| 199 | if (is_array($queryarray) && $count = count($queryarray)) { |
|
| 200 | $sql .= " AND ((d.value LIKE '%$queryarray[0]%' OR i.title LIKE '%$queryarray[0]%' OR t.description LIKE '%$queryarray[0]%')"; |
|
| 201 | for ($i = 1; $i < $count; ++$i) { |
|
| 202 | $sql .= " $andor "; |
|
| 203 | $sql .= "(d.value LIKE '%$queryarray[$i]%' OR i.title LIKE '%$queryarray[$i]%' OR t.description LIKE '%$queryarray[$i]%')"; |
|
| 204 | } |
|
| 205 | $sql .= ') '; |
|
| 206 | } |
|
| 207 | $result = $xoopsDB->query($sql) or $eh->show('0013'); |
|
| 208 | list($count) = $xoopsDB->fetchRow($result); |
|
| 209 | ||
| 210 | return $count; |
|
| 211 | } |
|
| 212 | ||