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

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

Hi Dave,

I think that I found a solution :

// get related citations
$citations = htmlentities(addslashes($record['title']));
$where = "MATCH (`title`) AGAINST (' .mysql_real_escape_string($citations). ' IN BOOLEAN MODE)";

list($relatedCitations, $relatedCitationsMetaData) = getRecords(array(
'tableName' => 'citations',
'where' => $where,
'allowSearch' => false,
));
-----------------------------------------
You think that it is a use correct with CMSBuilder ?
It is possible to optimize this with the use of several table and [font "Times New Roman"]perhaps [font "Times New Roman"]leftJoin ?

Thanks for your feedback ! Djulia

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