public function __construct($table, $pk = 'id') { $this->table = $table; $this->pk = $pk; if (self::$_db == null) { $config = Config::get('database'); $dsn = $config['driver'] . ':host=' . $config['host'] . ';dbname=' . $config['database']; self::$_db = new Service\Db($dsn, $config['username'], $config['password']); } }
public static function getMenuWithOneActive($params) { //title, type, active, href, id, imgSrc self::$_db = dbMysql::getInstance(); if (self::$_db) { if (self::_exists("gallerySections", "href", $params["params"]["name"])) { $sql = "select request as \"href\", html_id as \"id\", imgSrc,"; $sql .= " ( select term from dic_data where up = " . self::DIC_MENU_ITEM_TYPE . " and code = type ) as \"type\","; $sql .= " case when href = '" . $params["params"]["name"] . "' then 'true' else 'false' end as \"active\""; $sql .= " from gallerySections order by type, ord"; $res = self::$_db->fireSQL($sql); $vars = Request::getAllVar(); for ($i = 0; $i < count($res); $i++) { //$vars[ "params" ][ "name" ] = $res[ $i ][ "href" ]; //$vars[ "show" ] = "gallery"; $res[$i]["href"] = $_SERVER["PHP_SELF"] . "?" . $res[$i]["href"]; //Registry::get( "requestTemplate" )->getRequestString( $vars ); } //print_r( $res ); die; return $res; } } return NULL; }
private static function getDB() { if (!self::$_db) { self::$_db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE); if (self::$_db->connect_error) { throw new Exception("SQL connect failed: " . self::$_db->connect_error); } self::$_db->set_charset("utf8mb4"); self::dbCheckError(); } return self::$_db; }