Filtering By Keywords
Permalink
This is more of a MySQL question than a c5 question, so forgive my lack of DB syntax knowledge.
Why do the UserList and PageList filters use .'s in their queries?
Example:And:
Notice the 'u.uEmail' and 'u.uName' in the UserList example and 'psi.cName', etc... in the PageList example.
What are the prefixes for and how can they be taken advantage of?
Thanks!
- IJ
Why do the UserList and PageList filters use .'s in their queries?
Example:
public function filterByKeywords($keywords) { $db = Loader::db(); $qkeywords = $db->quote('%' . $keywords . '%'); $keys = UserAttributeKey::getSearchableIndexedList(); $emailSearchStr=' OR u.uEmail like '.$qkeywords.' '; $attribsStr = ''; foreach ($keys as $ak) { $cnt = $ak->getController(); $attribsStr.=' OR ' . $cnt->searchKeywords($keywords); } $this->filter(false, '( u.uName like ' . $qkeywords . $emailSearchStr . $attribsStr . ')'); }
public function filterByKeywords($keywords) { $db = Loader::db(); $kw = $db->quote($keywords); $qk = $db->quote('%' . $keywords . '%'); $this->indexedSearch = true; $this->indexedKeywords = $keywords; $this->autoSortColumns[] = 'cIndexScore'; Loader::model('attribute/categories/collection'); $keys = CollectionAttributeKey::getSearchableIndexedList(); $attribsStr = ''; foreach ($keys as $ak) { $cnt = $ak->getController(); $attribsStr.=' OR ' . $cnt->searchKeywords($keywords); } $this->filter(false, "((match(psi.cName, psi.cDescription, psi.content) against ({$kw})) {$attribsStr})");
Viewing 15 lines of 16 lines. View entire code block.
Notice the 'u.uEmail' and 'u.uName' in the UserList example and 'psi.cName', etc... in the PageList example.
What are the prefixes for and how can they be taken advantage of?
Thanks!
- IJ
http://w3schools.com/sql/sql_alias.asp...