public function __call($function, $args) { $re = '/(' . join('|', array_keys(array_map('preg_quote', $this->_queryTypes))) . ')(.+?)(?:By(.+))*$/'; if (preg_match($re, $function, $matches)) { $queryType = $matches[1]; if (isset($this->_queryTypes[$queryType])) { $temp = str_split($matches[2]); $temp[0] = strtolower($temp[0]); $method_names = array('_' . $queryType . $matches[2] . 'Query', '_' . join($temp) . 'Query'); $queryMethod = $this->_queryTypes[$queryType]; if (isset($matches[3])) { array_unshift($method_names, '_' . $queryType . $matches[2] . 'ByQuery'); if (Zend_Version::compareVersion('1.7.9') < 0) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $field = strtolower($filter->filter($matches[3])); } else { $field = strtolower(Zend_Filter::filterStatic($matches[3], 'Word_CamelCaseToUnderscore')); } array_unshift($args, $field); } foreach ($method_names as $method) { if (method_exists($this, $method)) { $sql = call_user_func_array(array($this, $method), $args); return $this->{$queryMethod}($sql); break; } } die("Cannot find proper query method for function <b>" . $function . "</b> of class " . get_class($this)); } } de('Table.php: ', $function, $args); return parent::__call($function, $args); }