Perhaps I misunderstand the thinking behind the operator, but when using the "OR" operator, I get the following errors with my view:
* warning: implode() [function.implode]: Bad arguments. in /sites/all/modules/views_fastsearch/views_fastsearch.module on line 140.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1 query: SELECT count(node.nid) FROM node node LEFT JOIN users_roles users_roles ON node.uid = users_roles.uid INNER JOIN users users ON node.uid = users.uid LEFT JOIN content_type_bio node_data_field_first_name ON node.vid = node_data_field_first_name.vid LEFT JOIN content_type_bio node_data_field_last_name ON node.vid = node_data_field_last_name.vid WHERE (users_roles.rid = '3') AND (node.type IN ('bio')) AND (()) in /includes/database.mysql.inc on line 172.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY node_data_field_last_name_field_last_name_value ASC LIMIT 0, 50' at line 1 query: SELECT node.nid, users.uid AS users_uid, node_data_field_first_name.field_first_name_value AS node_data_field_first_name_field_first_name_value, node_data_field_last_name.field_last_name_value AS node_data_field_last_name_field_last_name_value FROM node node LEFT JOIN users_roles users_roles ON node.uid = users_roles.uid INNER JOIN users users ON node.uid = users.uid LEFT JOIN content_type_bio node_data_field_first_name ON node.vid = node_data_field_first_name.vid LEFT JOIN content_type_bio node_data_field_last_name ON node.vid = node_data_field_last_name.vid WHERE (users_roles.rid = '3') AND (node.type IN ('bio')) AND (()) ORDER BY node_data_field_last_name_field_last_name_value ASC LIMIT 0, 50 in /includes/database.mysql.inc on line 172.
Currently I'm working around this, but I'd like to be able to do an OR based keyword search.
Here's the view export, for yr reference:
$view = new stdClass();
$view->name = 'directory';
$view->description = 'Staff Directory';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'IFTF Staff Directory';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'table';
$view->url = 'people/directory';
$view->use_pager = TRUE;
$view->nodes_per_page = '50';
$view->menu = TRUE;
$view->menu_title = 'directory';
$view->menu_tab = FALSE;
$view->menu_tab_weight = '0';
$view->menu_tab_default = FALSE;
$view->menu_tab_default_parent = NULL;
$view->menu_tab_default_parent_type = 'tab';
$view->menu_parent_tab_weight = '0';
$view->menu_parent_title = '';
$view->sort = array (
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'users',
'field' => 'uid',
'label' => '',
),
array (
'tablename' => 'node_data_field_first_name',
'field' => 'field_first_name_value',
'label' => 'First Name',
'handler' => 'content_views_field_handler_group',
'sortable' => '1',
'options' => 'default',
),
array (
'tablename' => 'node_data_field_last_name',
'field' => 'field_last_name_value',
'label' => 'Last Name',
'handler' => 'content_views_field_handler_group',
'sortable' => '1',
'defaultsort' => 'ASC',
'options' => 'default',
),
);
$view->filter = array (
array (
'tablename' => 'users_roles',
'field' => 'rid',
'operator' => 'AND',
'options' => '',
'value' => array (
0 => '3',
),
),
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'bio',
),
),
array (
'tablename' => 'search_index',
'field' => 'word',
'operator' => 'AND+',
'options' => '',
'value' => '',
),
);
$view->exposed_filter = array (
array (
'tablename' => 'search_index',
'field' => 'word',
'label' => '',
'optional' => '1',
'is_default' => '0',
'operator' => '1',
'single' => '0',
),
);
$view->requires = array(users, node_data_field_first_name, node_data_field_last_name, users_roles, node, search_index);
$views[$view->name] = $view;
Comments
Comment #1
mlsamuelson commentedI'm having the same error. I believe I identified a logic error on line 81 which would result in an "always true" when the "or" operator is being used - meaning that the logic check following it would never fire for subsequent iterations of the containing foreach loop, which appeared to be the intent.
I've made a patch that resolves the errors on the view page and results in successful queries with the view, I still see the following on the edit page for the view only when the OR operator is selected:
I'm out of time at the moment and have to get to an appointment, so I thought I'd share what I have thus far...
Comment #2
douggreen commentedPlease use the 5.x-2.x version.
Comment #3
douggreen commentedbtw, I don't think this is a logic error.
Comment #4
mlsamuelson commentedThanks douggreen!
The 5.x-2.x version resolves the issue.
I'm guessing it's an unrelated issue but on the view page and the edit page for the view I do still get
when the filter is not marked "optional" and before any searches have been conducted.
mlsamuelson
Comment #5
lee20 commentedSubscribing....I have the same issue with the same configurtion, OR search with the filter not marked optional.
Comment #6
lee20 commentedAfter stepping through a backtrace of the error, it seems when the exposed filter is themed through "theme_textfield", the $element['#value'] is an empty array. I am not sure what is setting this to an array, but it appears to be a possible bug in the Views module, or an issue with how the fast search filter is interacting with views. At any case, this is a work around to preventing the error:
Comment #7
trantr commentedDear Lee20
I got problem with using OR search without checking the Optional in Exposed Filter, can you tell me where i place this code for the work around?