Doctrine_Query dein Freund und Helfer
Wie lange hab ich von dem Tag geträumt. Endlich kann ich mit dem neuen ORM den Shop neu bauen. Hier z.B. die Such-Funktion – ihr wollt nicht wissen was die vorher alles an SQL gemacht hat. Diese hier ist auch gleich mal 75% schneller als die alte.
-
function search ($pos, $count, $orderBy) {
-
‘c_nr’,
-
‘name’,
-
‘description’,
-
‘description_detail’,
-
);
-
$list = Doctrine_Query::create()
-
->from (‘ShopArticle a’);
-
if ( ! $this->ShopLanguage->fl_default) {
-
$list->leftJoin (‘a.ShopArticleText at’)
-
->leftJoin (‘at.ShopLanguage atl’)
-
->addWhere (‘atl.id = ‘ . $this->ShopLanguage->id);
-
}
-
$list->orderBy (‘a.’ . $orderBy)
-
->offset ($pos)
-
->limit ($count);
-
foreach ($this->getclean () as $s) {
-
foreach ($searchFields as $f) {
-
$list->orWhere (‘a.fl_disabled = 0′)
-
->addWhere (‘a.fl_category_hide = 0′)
-
->addWhere (‘a.fl_soldout = 0′);
-
if ($f == ‘c_nr’ || $this->ShopLanguage->fl_default) {
-
// Default Sprache und c_nr ist in der Artikeltabelle
-
$list->addWhere ($f . ‘ LIKE ?’, ‘%’ . $s . ‘%’);
-
} else {
-
// Alles andere in der ArticleText Tabelle mit unserer Sprache
-
$list->addWhere (‘at.’ . $f . ‘ LIKE ?’, ‘%’ . $s . ‘%’);
-
}
-
}
-
}
-
return $list;
-
}
