I'm new to Zend Framework. Can you help me optimize this function, which gets a list of Manufactures
with some conditions from a database?
private function Manufactures(
$Condition = array(),
$Order = array('name' => 'ASC'),
$Strict = TRUE,
$Limit = NULL)
{
$Request = $this->_DbTable->select();
$Clause = $Strict ? '=' : 'LIKE';
foreach ($Condition as $index => $value) {
if (!is_array($value)) {
$Request->where($this->_DbTable->info('name') . '.' . $index . ' '. $Clause .' ?', $value);
} else {
foreach ($value as $key => $val) {
if (is_array($val)) {
foreach ($val as $valIndex) {
if (isset($valIndex['modifier']) && isset($valIndex['value'])) {
$Request->where($this->_DbTable->info('name') . '.' . $key . ' ' . $valIndex['modifier']. ' ?', $valIndex['value']);
}
}
}
}
}
}
foreach ($Order as $index => $value) {
$Request->order($index . ' ' . $value);
}
if($Limit) $Request->limit($Limit);
$Data = $this->_DbTable->fetchAll($Request)
->toArray();
return isset($Data) ? $Data : NULL;
}