]>
src.bluestatic.org Git - bugdar.git/blob - includes/db_mysql.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # [#]app[#] [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
22 var $current_query = '';
23 var $query_history = array();
25 var $appname = 'Databsase Abstraction Layer';
27 function connect($server, $user, $password, $pconnect)
29 if ($this->link_id
== 0)
33 $this->link_id
= @mysql_pconnect($server, $user, $password);
37 $this->link_id
= @mysql_connect($server, $user, $password);
42 $this->throw('Link-Id == false, can not connect');
46 $candb = @mysql_select_db($this->database
, $this->link_id
);
53 $this->throw('Cannot use the database ' . $this->database
);
58 function query($qstring)
60 $this->query_id
= mysql_query($qstring, $this->link_id
);
61 $this->current_query
= $qstring;
62 $this->query_history
[] = $this->current_query
;
66 $this->throw('Invalid SQL query: ' . $this->current_query
);
69 return $this->query_id
;
72 function fetch_array($query_id)
74 return @mysql_fetch_array($query_id, MYSQL_ASSOC
);
77 function free_result($query_id)
79 @mysql_free_result($query_id);
83 function query_first($qstring)
85 $resource = $this->query($qstring);
86 $array = $this->fetch_array($resource);
87 $this->free_result($resource);
93 return mysql_insert_id($this->link_id
);
96 function num_rows($query_id)
98 return @mysql_num_rows($query_id);
101 function affected_rows()
103 return @mysql_affected_rows($this->link_id
);
106 function throw($message)
110 $this->error
= mysql_error($this->link_id
);
111 $this->errno
= mysql_errno($this->link_id
);
114 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r";
115 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r<head>\r<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r<title>";
116 echo "{$this->appname} Error</title>\r<style type=\"text/css\">\r<!--\r.title\r{\r\tfont-family: Arial, Helvetica, sans-serif;\r\tfont-size: 12px;\r\tcolor: #990000;";
117 echo "\r}\rbody\r{\r\tfont-family: Arial, Helvetica, sans-serif;\r\tfont-size: 11px;\r}\r.code\r{\r\tfont-family: \"Courier New\", Courier, mono;\r\tfont-size: 11px;\r}";
118 echo "\r-->\r</style>\r</head>\r\r<body>\r<p class=\"title\"><strong>An error occured in <em>{$this->appname}</em></strong></p>\r\r<p>\r\t<blockquote>\r\t\t»";
119 echo "<strong>Query:</strong>\r\t\t<br />\r\t\t<pre class=\"code\">{$this->current_query}</pre>\r\t\t<br />\r\t\t»<strong>Error Number:</strong> ";
120 echo "<span class=\"code\">{$this->errno}</span>\r\t\t<br />\r\t\t<br />\r\t\t»<strong>Error Message:</strong> <span class=\"code\">{$this->error}</span>\r\t\t";
121 echo "<br />\r\t\t<br />\r\t\t»<strong>File:</strong> <span class=\"code\">$_SERVER[PHP_SELF]</span>\r\t</blockquote>\r</p>\r\r</body>\r</html>";
128 /*=====================================================================*\
129 || ###################################################################
132 || ###################################################################
133 \*=====================================================================*/