List data from table in Detail page

15 posts by 4 authors in: Forums > CMS Builder
Last Post: August 4, 2009   (RSS)

By Djulia - August 3, 2009 - edited: August 3, 2009

Hi Dave,

You think that it is possible to use Boolean search for where ?

For example :

$where = MATCH(title) AGAINST (' .mysql_real_escape_string( $record['title'] ). ' IN BOOLEAN MODE);
list($relatedCitations, $relatedCitationsMetaData) = getRecords(array(
'tableName' => 'citations',
'where' => $where,
'allowSearch' => false,
));

Thanks for your answer.

Djulia

Re: [Djulia] List data from table in Detail page

By Dave - August 4, 2009

Hi Djulia,

Yes, you could do it that way. What kind of search are you trying to perform though? If it's just an exact match it would be simpler to just use:
$where = " title = '" .mysql_real_escape_string($citations). "'";

But if you want to use your code just add these quotes in red:

$where = "MATCH (`title`) AGAINST ('" .mysql_real_escape_string($citations). "' IN BOOLEAN MODE)";

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

By Djulia - August 4, 2009

Hi Dave,

Thank you for your correction. [:)]

Title can contain several words and I want to obtain a result if ' word 1 OR word 2 OR word 3... ' is in the title.

My base of research to obtain my solution :
----------------------------------------------------------------------------------
'apple banana'
Find rows that contain at least one of the two words.
http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html
----------------------------------------------------------------------------------

LIKE, does not seem to be able to give this possibility.
But, perhaps I am mistaken ?

Djulia

Re: [Djulia] List data from table in Detail page

By Dave - August 4, 2009

No, you're right, with LIKE you'd have to do:

`fieldname` LIKE "%keyword1%" OR
`fieldname` LIKE "%keyword2%"

Another way would be:

`fieldname` = "word1" OR `fieldname` = "word2"

Or:

`fieldname` IN ('word1', 'word2');

Good luck! :)
Dave Edis - Senior Developer
interactivetools.com