View more context

 

nightjarnz

Not sure how well it works with MATCH though :< These are parts of the ORM I've seldom had to dive into.

phyzical

its been awhile but some... thinggs are supported via :

taoceanz

That's a decent idea too. I looked at SQLQuery though wasn't sure about Distinct and Match

taoceanz

This may be sufficient perhaps

  1. $sql = implode(
  2. ' ',
  3. [
  4. 'SELECT DISTINCT SiteTree_Live.ID, SiteTree_Live.Title,',
  5. "MATCH ({$sitetreetables}) AGAINST (?) AS Relevance",
  6. 'FROM SiteTree_Live',
  7. "LEFT JOIN SiteTree_Localised AS {$sitetree_table_localised}",
  8. "ON SiteTree_Live.ID = {$sitetree_table_localised}.RecordID AND {$sitetree_table_localised}.Locale = ? AND (({$sitetree_table_localised}.ID IS NOT NULL))",
  9. "WHERE (MATCH ({$sitetreetables}) AGAINST (? IN BOOLEAN MODE) + MATCH ({$sitetreetables}) AGAINST (? IN BOOLEAN MODE) AND SiteTree_Live.ShowInSearch <> 0)",
  10. 'ORDER BY Relevance DESC',
  11. 'LIMIT 20'
  12. ]
  13. );
  14. $params = [
  15. $keywords_strrpl,
  16. $current_locale,
  17. $keywords,
  18. $htmlEntityKeywords
  19. ];
  20. $custom_results = DB::prepared_query($sql, $params);
nightjarnz

sitetree_table_localised haha, but why though? :> The variable is more chars than the actual name, and is static anyway (never reassigned).

nightjarnz

seems like a better use of params in any case :)

taoceanz

It's dynamically created the be set to the current locale so ends up like SiteTree_Localised_en_US or SiteTree_Localised_zh_cmn. I'd prefer not to repeat SiteTree_Localised_{$current_locale} multiple times.

  1. $current_locale = FluentState::singleton()->getLocale();
  2. $sitetree_table_localised = "SiteTree_Localised_{$current_locale}";