public static function getConnection() { if (self::$db == null) { self::$db = new ExtMysql(); } return self::$db->connection; }
/** * ExtDbSqlObject::__construct() * * @param mixed $query * @return */ public function __construct($query) { $this->result = mysqli_query(ExtMysql::getConnection(), $query); $this->data = mysqli_fetch_object($this->result); $this->freeResult(); }
/** * ExtDbSqlModel::buildQuery() * * @return */ public function buildQuery() { mysqli_query(ExtMysql::getConnection(), "SET CHARACTER SET utf8"); $this->obj_result = mysqli_query(ExtMysql::getConnection(), $this->str_query); $this->int_foundrows = mysqli_num_rows($this->obj_result); $this->int_pagecount = $this->int_foundrows / $this->int_showrows; $this->int_pagecount = ceil($this->int_pagecount); if ($this->int_foundrows < $this->int_showrows) { $this->obj_result = mysqli_query(ExtMysql::getConnection(), $this->str_query); } else { $this->obj_result = mysqli_query(ExtMysql::getConnection(), "" . $this->str_query . "" . " limit " . ($this->int_startrow - 1) . ", " . $this->int_showrows); } try { if (!$this->obj_result) { throw new ExtException('Cant built model.'); } } catch (ExtException $e) { echo $e->errMsg(); } }