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

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