opencart-query-builder
opencart-query-builder copied to clipboard
+ function sql_replace
Позволит из контроллера модуля изменять стандартные запросы без модификаторов. Пример использования:
<?php
class ControllerExtensionModuleMyModule extends Controller {
static $module_id = 0;
// $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'my_module', `trigger` = 'catalog/controller/*/before', `action` = 'extension/module/my_module/eventControllerBefore', `status` = '1', `date_added` = now()");
public function eventControllerBefore(&$route, &$data = null, &$output = null) {
}
// $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'my_module', `trigger` = 'catalog/model/*/before', `action` = 'extension/module/my_module/eventModelBefore', `status` = '1', `date_added` = now()");
public function eventModelBefore(&$route, &$data = null, &$output = null) {
if ($route == 'catalog/category/getCategory') {
if ($this->module_id++ == 1) {
$this->db->sql_replace("SELECT DISTINCT * FROM " . DB_PREFIX . "category", "SELECT DISTINCT *, c.category_id AS new_column FROM " . DB_PREFIX . "category");
}
}
}
// $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'my_module', `trigger` = 'catalog/controller/*/before', `action` = 'extension/module/my_module/eventControllerAfter', `status` = '1', `date_added` = now()");
public function eventControllerAfter(&$route, &$data = null, &$output = null) {
}
// $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'my_module', `trigger` = 'catalog/model/*/before', `action` = 'extension/module/my_module/eventModelAfter', `status` = '1', `date_added` = now()");
public function eventModelAfter(&$route, &$data = null, &$output = null) {
}
public function index() {
$this->db->enableLog();
$this->load->model('catalog/category');
$this->model_catalog_category->getCategory(59);
$this->model_catalog_category->getCategory(59);
// Available methods
//$queries = $this->db->getExecutedQueries();
$this->db->printExecutedQueries();
}
}