123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- class mysql {
- var $error = "";
- var $result = false;
- var $link = null;
- function mysql () {
- global $dsn;
- $this->link = mysqli_connect ($dsn['hostspec'], $dsn['username'], $dsn['password']) or die("could not connect to db");
- if (!$this->link) {
- echo "Error: Unable to connect to MySQL." . PHP_EOL;
- echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
- echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
- exit;
- }
-
- if ( ! mysqli_select_db ($this->link, $dsn['database'])) {
- $this->error = mysqli_error ($this->link);
- }
- }
- function query ($query) {
- if ($this->result = mysqli_query ($this->link, $query)) {
- return true;
- }
- else{
- $this->error = mysqli_error ($this->link);
- return false;
- }
- }
- function escape ($string) {
- return mysqli_real_escape_string ($this->link, $string);
- }
- }
- ?>
|