What is the best way to search for a string against title, name, abstract, and body of the articles? Does midgard have a built in function for doing this or do I have to parse all the text from all articles to find what I'm searching for?
I prefer direct access to the db like this:
<?php
$sqlab = "";
if ($and) {
$and_array = explode(' ', $and);
foreach ($and_array as $str) {
$sqlab.= ' AND (article_i.content REGEXP "[[:<:]]'.$str.'[[:>:]]" OR article_i.abstract REGEXP "[[:<:]]'.$str.'[[:>:]]" OR article_i.title REGEXP "[[:<:]]'.$str.'[[:>:]]")';
}
}
if ($or) {
$sqlab.= ' AND (';
$or_array = explode(' ', $or);
foreach ($or_array as $str) {
$sqlab.= ' article_i.content REGEXP "[[:<:]]'.$str.'[[:>:]]" OR article_i.abstract REGEXP "[[:<:]]'.$str.'[[:>:]]" OR article_i.title REGEXP "[[:<:]]'.$str.'[[:>:]]" OR';
}
$sqlab = substr($sqlab, 0, (strlen($sqlab)-3));
$sqlab.= ')';
}
$query = "
SELECT
article.id,
article.topic,
article.name,
article.created,
article.sitegroup,
article_i.url,
article_i.title,
article_i.abstract,
article_i.content
FROM article, article_i
WHERE
article.sitegroup=".SITEGROUP_ID."
AND article.created<NOW()
".$sqlab."
AND article.id=article_i.sid
ORDER BY article.created DESC";$res = mysql_query ($query);
?>
Axel
-- Axel Gebauer [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
