Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class mysql {
- public $local;
- public $table;
- public $user;
- public $pass;
- public $link;
- public $db;
- private function mysql($local, $user, $pass, $link, $db) {
- $this->local = $local;
- $this->user = $user;
- $this->pass = $pass;
- $this->link = $link;
- $this->db = $db;
- $this->link = mysql_connect($this->local, $this->user, $this->pass);
- if(!$link) {
- die("error in the connect");
- return false;
- }
- if(mysql_select_db($this->db,$this->link)) {
- mysql_select_db($this->db,$this->link);
- } else {
- mysql_query("CREATE DATABASE ".$this->db, $this->link);
- }
- return true;
- }
- private function create_db($db_name) [
- return mysql_query("CREATE DATABASE ".$db_name, $this->link);
- }
- private function query($query) {
- return mysql_query($query, $this->link) or die(mysql_error());
- }
- private function nums($query) {
- return mysql_num_rows($query);
- }
- private function fetch_assoc($query) {
- return mysql_fetch_assoc($query);
- }
- private function fetch_array($query) {
- return mysql_fetch_array($query);
- }
- private function drop_db($db_name) {
- return mysql_query("DROP DATABASE ".$db_name, $this->link) or die(mysql_error());
- }
- private function close() {
- return mysql_close();
- }
- }
- class template() {
- public $file_src;
- public $read_tpl;
- public $open_tpl;
- private function template($tpl_src) {
- $this->file_src = $tpl_src;
- if(file_exists($this->file_src)) {
- $this->open_tpl = fopen($tpl_src, "r+");
- $this->read_tpl = fread($this->open_tpl, filesize($tpl_src));
- } else {
- $this->file_src = null;
- die("the file tpl not exists");
- }
- }
- private function set_text($search, $replace) {
- $this->read_tpl = str_replace("[@".$search."]", $text, $this->read_tpl);
- }
- private function tpl() {
- echo $read_tpl;
- }
- private function close() {
- return fclose($this->open_tpl);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement