View more context



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


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);

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


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


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}";

Hey Dylan, for future reference, many of us feel like we need to be light in our opinions about someone else or their work as to not hurt their feelings. Just fyi, I'm not fussed what your thoughts are on my questions or code so long as you explain why. If you think my code is junk, I'm not fused so long as you explain why it's so bad and what could be done to improve it. Don't feel you need to send emoji smiley faces on my account when critiquing me. If that makes sense.


Same goes for anyone critiquing me. Growth is achieved through truth.