static function getDatasourceGroupByKey() { $sql = ''; $langs = self::getAll(); foreach ($langs as $l) { $sql .= '(SELECT translate FROM [lang_translate] WHERE [main].[key] = [lang_translate].[key] AND id_lang = ' . $l['id_lang'] . ') AS ' . $l['iso'] . ','; } return dibi::dataSource("\n\t\t\tSELECT\n\t\t\t\t" . $sql . "\n\t\t\t\t[key]\n\t\t\tFROM\n\t\t\t\t[lang_translate] main\n\t\t\tGROUP BY [key]"); }
public static function getItem($source, $id) { $result = dibi::dataSource('SELECT * FROM %n WHERE id = %i', $source, $id); $data = $result->fetchAll(); if (count($data) > 0) { return $data[0]; } else { return null; } }
function showLog() { $session = NEnvironment::getSession('Log'); if (isset($_GET['order_by'])) { if ($_GET['order_by'] != "date" and $_GET['order_by'] != "id_user" and $_GET['order_by'] != "description" and $_GET['order_by'] != "value" and $_GET['order_by'] != "value" and $_GET['order_by'] != "id_type_modul" and $_GET['order_by'] != "ip") { $session['log_order_by'] = "date"; } else { $session['log_order_by'] = $_GET['order_by']; } } if (!isset($session['log_order_by'])) { $session['log_order_by'] = "date"; } $source = dibi::dataSource("\n\t\t\tSELECT log.*, user.login \n\t\t\tFROM log LEFT JOIN user USING(id_user) \n\t\t\tWHERE\n\t\t\t\t%if", @$_GET['input_id_user'] != '', "login LIKE %s", '%' . @$_GET['input_id_user'] . '%', " AND %end\n\t\t \t%if", @$_GET['input_date'] != '', "[date] > %s", @$_GET['input_date'], " AND %end\n\t\t\t %if", @$_GET['input_description'] != '', "description LIKE %s", '%' . @$_GET['input_description'] . '%', " AND %end\n\t\t\t %if", @$_GET['input_value'] != '', "value LIKE %s", '%' . @$_GET['input_value'] . '%', " AND %end\n\t\t\t %if", @$_GET['input_id_type_modul'] != '', "name_modul LIKE %s", '%' . @$_GET['input_id_type_modul'] . '%', " AND %end\n\t\t\t ip LIKE %s", '%' . @$_GET['input_ip'] . '%', " \n\t\t \n\t\t ORDER BY " . $session['log_order_by'] . " DESC"); $p = new MyPaginator($source); MT::addTemplate(dirname(__FILE__) . '/log.phtml', 'log'); MT::addVar('log', 'paginator', $p); MT::addVar('log', 'list', $p->getDataSourceItem()->fetchAll()); }
function getDataSource() { return dibi::dataSource("SELECT * FROM log"); }
public static function getClosedTickets($id) { $rowset = dibi::dataSource('SELECT id, ticketId, priority, name, subject, status, updated FROM ticket WHERE (departmentId=%i) AND (closed=%i) ORDER BY updated DESC', $id, 1); return $rowset; }
public static function getUsers() { $rowset = dibi::dataSource('SELECT * FROM user'); return $rowset; }
static function getDatasource() { return dibi::dataSource("SELECT * FROM [" . TABLE_USERS . "]"); }
static function getTreeCheckProduct($id_product = null) { return dibi::dataSource("\n\t\t\tSELECT\n\t\t\t*, id_category AS id\n\t\t\t%if", $id_product, "\n\t\t\t\t,\n\t\t\tIF (\n\t\t\t\t(SELECT\n\t\t\t\t1\n\t\t\t\tFROM\n\t\t\t\t[category_product]\n\t\t\t\tWHERE\n\t\t\t\tid_product = %i", $id_product, "AND category_product.id_category = id LIMIT 1) = 1,\n\t\t\t\t1,\n\t\t\t\t0\n\t\t\t) AS cb\n\t\t\t%end\n\t\t\tFROM\n\t\t\t[category]\n\t\t\tLEFT JOIN [category_lang] USING(id_category)\n\n\n\t\t"); }
static function getDatasource() { return dibi::dataSource("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t[order]\n\t\t\tWHERE \n\t\t\t\tdeleted = 0\n\t\t\t"); }
static function getProductParamDatasource($id_product) { //POZOR upravi cenu podla zadavania dane SHOW_PRICE_WITH_TAX $tax_coef = self::getTaxCoefForProduct($id_product); $product_param_cols = Tools::getCollum('product_param'); unset($product_param_cols['price']); // dump($product_param_cols);exit; return dibi::dataSource("\n\t\t\tSELECT \n\t\t\t%sql", implode(',', $product_param_cols), "\n\t\t\t, ROUND((price*" . $tax_coef . "),2) AS price\n\t\t\tFROM \n\t\t\t[product_param] \n\t\t\tWHERE %if", $id_product == null, " id_product IS NULL %else id_product = %i", $id_product); }