MultiSearch Filtering Functions

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2011   (RSS)

By Rusty - February 1, 2011 - edited: February 8, 2011

I'm trying to filter/limit the results provided by MultiSearch.php . I want to limit it so that it only searches records based upon a where statement.

'where' => 'permission = ' . @$CURRENT_USER['num'],

I've tried ALL kinds of combinations and can't get it sorted.

Closest I've gotten is this, but it doesn't do anything. And the really annoying thing is the MySQL debug shows me that the WHERE statement is there... I can't figure out how to add too it though.

<?php
require_once "/website.com/html/admin/lib/viewer_functions.php";
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "1";
This doesn't do anything, though I wish it did
$searchOptions['where'] = "permission =" . @$CURRENT_USER['num'];

$searchTables = array();
$searchTables['forms'] = array(
'viewerUrl' => 'form-detail.php',
'titleField' => 'title',
'summaryField' => 'description',
'searchFields' => array('title','form_number','description'),

);

$searchTables['order_history'] = array(
'viewerUrl' => 'order_history.php',
'titleField' => 'order_num',
'summaryField' => 'content',
'searchFields' => array('order_num','placed_by'),

);

list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);

?>

Rusty

Re: [Rusty] MultiSearch Filtering Functions

By Jason - February 1, 2011

Hi Rusty,

searchMultipleTables() doesn't support a manual "where" option. It just searches the specified fields from the specified tables against what you entered in the text box.

There are a couple of options to accomplish what you're trying to do. You could filter your results by checking the value of fields as you loop through them. Another option would be to not use MultiSearch and instead to two getRecords calls and create manual where clauses for those.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] MultiSearch Filtering Functions

By Rusty - February 8, 2011

This is somewhat related... I'm trying to filter content based upon the presence of a users UserNum in an array. The array is created by an admin who makes entries via a multi-select drop down list with CMS.

I know you said you that searchMultipleTables() doesn't support a manual "where" option, but what about the ability to search ONE table? I just need to check each table to see if a userNum is present in that record, and then IF it's true show that record, otherwise continue to the next and try again.
Rusty