Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class db{
- public $connection;
- public $server;
- public $port;
- public $username;
- public $password;
- public $database;
- //CORE
- public function __construct($server, $username, $password, $database, $port = false, $preserve = false)
- {
- $this->server = $server;
- $this->username = $username;
- $this->password = $password;
- $this->database = $database;
- if($port === false)
- {
- $port = 3306;
- $this->port = $port;
- }
- if($preserve)
- {
- $this->connection = mysql_pconnect($this->server.':'.$this->port, $this->username, $this->password);
- }
- else
- {
- $this->connection = mysql_connect($this->server.':'.$this->port, $this->username, $this->password);
- }
- if($this->connection)
- {
- mysql_select_db($this->database, $this->connection);
- }
- }
- public function __destruct()
- {
- mysql_close($this->connection);
- }
- //REQUEST
- public function sql_query($sql)
- {
- return mysql_query($sql, $this->connection);
- }
- public function sql_search($search)
- {
- $search = mysql_real_escape_string($search, $this->connection);
- $sql = "SELECT * FROM wikpost
- WHERE MATCH (pTopic, pText)
- AGAINST ('".$search."')";
- $query = mysql_query($sql, $this->connection);
- return mysql_fetch_array($query);
- }
- public function sql_escape($sql)
- {
- return mysql_real_escape_string($sql, $this->connection);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement