public static function query($_tbname) { $db = \hmvc\Db\Db::getConnection(); $_tbname = $db->tb_name($_tbname); $resources = $db->query("SELECT *,CONCAT( path, '-', sort_order ) AS path\r\n FROM `{$_tbname}` ORDER BY sort_order ASC,id DESC"); $result = array(); self::sort(0, 0, $resources, $result); return $result; }
public function count($str, $data = false, $db = false) { if (!$db) { $db = \hmvc\Db\Db::getConnection(); } if ($data && is_array($data)) { $row = $db->getRow(vsprintf($str, $data), MYSQLI_NUM); } else { $row = $db->getRow($str, MYSQLI_NUM); } if (isset($row[0])) { $this->_total_rows = intval($row[0]); } $this->_init(); return $this->_total_rows; }
public function db($_dbname = 'db') { return \hmvc\Db\Db::getConnection($_dbname); }
/** * 最小的ID 是Admin */ public function isSuperAdmin() { if (!$this->isLogin()) { redirect('index/login'); } Session::getInstance()->set('redirect', Application::app()->request()->curUrl()); $db = \hmvc\Db\Db::getConnection(); $user = $db->getRow("SELECT MIN( id ) as id FROM `h_admin`"); if ($user['id'] == $this->session->get('auth.id')) { return true; } return false; }