[TYPO3] problem with wfqbe (ext) and preProcessQueryStructure (hook)
Martin
ber.lin.ux at gmx.de
Tue Jan 22 23:45:59 CET 2008
Hi All!
I recently installed the wfqbe-extension which seems to provide a great
solution for the integration of an external database.
I'm trying to integrate a literature database for a university project.
One should be able to search the DB by author, title, descriptors and
the like.
The query structure looks like this:
SELECT * FROM dbliterature WHERE ( dbliterature.author LIKE
'%###WFQBE_AUTHOR###%' OR dbliterature.institution LIKE
'%###WFQBE_AUTHOR###%' ) AND ( dbliterature.title LIKE
'%###WFQBE_TITLE###%' OR dbliterature.journal_title LIKE
'%###WFQBE_TITLE###%' ) AND ( dbliterature.descriptor LIKE
'%###WFQBE_DESCRIPTOR###%' OR dbliterature.abstract LIKE
'%###WFQBE_DESCRIPTOR###%' )
I then created a search form page with the wfqbe-extension which
provides several input areas each connected to the according markers for
author, title, descriptors, etc. Leaving one of these input areas blank
(e.g. searching by an author's name only, not giving a search input for
"title") the extension should disregard the unused markers and generate
a MYSQL search query based on used inputs only.
Example:
author: Smith
title: nations
descriptor: BLANK
I used the hook mentioned in the extension's documentation
(preProcessQueryStructure) and configured it as described in a list post
(http://www.typo3board.com/ftopic12181.html), as follows:
class tx_wfqbe_preprocessquery {
function tx_wfqbe_preprocessquery() {
}
function process_query_structure($wfqbe, $piVars, $query_uid,
&$callingObj) {
$remove = array();
// Query to be processed
if ($query_uid==13) {
$markers = array(
"AUTHOR", "TITLE", "DESCRIPTOR"
);
foreach ($markers as $marcatore) {
if ($piVars[$marcatore]=='' ||
(is_array($piVars[$marcatore]) && $piVars[$marcatore][0]=='')) {
foreach ($wfqbe[0]['insert'] as $key => $value) {
if (strpos($value, 'WFQBE_'.$marcatore)>0) {
$remove[] = $key;
unset($wfqbe[0]['insert'][$key]);
}
}
}
}
}
return $remove;
}
}
The extension should then construct a query like this:
SELECT * FROM dbliterature WHERE ( dbliterature.author LIKE '%Smith%' OR
dbliterature.institution LIKE '%Smith%' ) AND ( dbliterature.title LIKE
'%nations%' OR dbliterature.journal_title LIKE '%nations%' )
What I do get, however, is this:
SELECT * FROM dbliterature WHERE ( dbliterature.author LIKE '%Smith%' OR
dbliterature.institution LIKE '%Smith%' ) AND ( dbliterature.title LIKE
'%nations%' OR dbliterature.journal_title LIKE '%nations%' ) ( '%%' '%%' )
(and, of course, the message "Query failed (uid=13)")
Any ideas or suggestions how to solve this?
Thank's very much,
regards, Martin (ber.lin.ux)
(using typo3 4.1.1 & wfqbe 1.0.6)
More information about the TYPO3-english
mailing list