[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Не пойму как работает
VadimVadim
$information_info = $this->model_catalog_information->getInformation($information_id);

Есть вот такой абсолютно работоспособный код и кусок из него выше. Этот код находится внутри класса class ControllerInformationInformation extends Controller {

Сам класс Controller от которого наследован ControllerInformationInformation

abstract class Controller {
protected $registry;
protected $id;
protected $template;
protected $children = array();
protected $data = array();
protected $output;

public function __construct($registry) {
$this->registry = $registry;
}

public function __get($key) {
return $this->registry->get($key);
}

public function __set($key, $value) {
$this->registry->set($key, $value);
}

protected function forward($route, $args = array()) {
return new Action($route, $args);
}

protected function redirect($url) {
header('Location: ' . str_replace('&', '&', $url));
exit();
}

protected function render($return = FALSE) {
foreach ($this->children as $child) {
$action = new Action($child);
$file = $action->getFile();
$class = $action->getClass();
$method = $action->getMethod();
$args = $action->getArgs();

if (file_exists($file)) {
require_once($file);

$controller = new $class($this->registry);

$controller->index();

$this->data[$controller->id] = $controller->output;
} else {
exit('Error: Could not load controller ' . $child . '!');
}
}

if ($return) {
return $this->fetch($this->template);
} else {
$this->output = $this->fetch($this->template);
}
}

protected function fetch($filename) {
$file = DIR_TEMPLATE . $filename;

if (file_exists($file)) {
extract($this->data);

ob_start();

require($file);

$content = ob_get_contents();

ob_end_clean();

return $content;
} else {
exit('Error: Could not load template ' . $file . '!');
}
}
}

Т.е. в нем нет model_catalog_information

А функция getInformation($information_id) нашлась в классе ModelCatalogInformation

class ModelCatalogInformation extends Model {
public function getInformation($information_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");//AND i.status = '1'

return $query->row;
}

public function getInformations() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' AND i.sort_order <> '-1' ORDER BY i.sort_order, LCASE(id.title) ASC");

return $query->rows;
}
}

В свою очередь ModelCatalogInformation наследован от Model

abstract class Model {
protected $registry;

public function __construct($registry) {
$this->registry = $registry;
}

public function __get($key) {
return $this->registry->get($key);
}

public function __set($key, $value) {
$this->registry->set($key, $value);
}
}

Вопросов куча: model_catalog_information - где это объявлено. По идее он должен иметь отношение к ModelCatalogInformation и Model. Но в том то и вся фишка, что information_model_catalog нигде не объявлен information_model_catalog = new Model или information_model_catalog = new ModelCatalogInformation. Вот никак этого не пойму!




Спустя 1 час, 15 минут, 1 секунда (11.08.2011 - 11:24) linker написал(а):
VadimVadim
Загляни в другие темы и проверь свой пост на предмет правильного оформления своего куска кода. Ломать себе глаза, читая твой пост, никто не будет.

Спустя 14 минут, 47 секунд (11.08.2011 - 11:39) Michael написал(а):

 ! 

М
И на будущее - давайте своим темам вменяемое название
Michael

Спустя 8 минут, 18 секунд (11.08.2011 - 11:47) TMake написал(а):
VadimVadim model_catalog_information - это смотри скорее всего название модели, должно находится в папки со всеми моделями, а там скорее всего идет extends Model
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.