/** * Generates and executes the search action * * @return array|bool Returns an array of Model classes or returns false * if there is no match */ public function find() { $this->queryAction = 'SELECT'; $query = $this->buildQuery(); $result = $this->queryFetch($query); if ($result) { $dataset = array(); foreach ($result as $row) { $model = new Model($this->name, false); foreach ($row as $column => $value) { $modelPath = explode(self::TABLE_NAME_SEPARATOR, $column); $modelPathLen = sizeof($modelPath); if ($modelPath[0] == $model->modelName()) { if ($modelPath[0] == $model->modelName() && $modelPathLen == 2) { $method = sprintf('set%s', $modelPath[1]); $model->{$method}($value); } else { $childModel = $model; for ($i = 1; $i < $modelPathLen - 1; $i++) { $method = sprintf('get%s', $modelPath[$i]); $childModel = $childModel->{$method}(); } $method = sprintf('set%s', $modelPath[$modelPathLen - 1]); $childModel->{$method}($value); } } } $dataset[] = $model; } return $dataset; } return false; }