Show mysql.php syntax highlighted
<?php
class DB extends DB_abstract implements DB_interface {
protected static $result;
protected static $Thread = null; // connection pointer object
protected static $lastQuery = null;
protected static $lastResult = null;
public static function Connect($host, $username, $passwd, $dbname, $prefix = false, $port = '', $socket = '') {
if ($prefix === false) exit('You must set DB::Prefix first.');
parent :: Connect($host, $username, $passwd, $dbname);
self :: $prefix = $prefix;
if ($port == '' || $socket == '') {
self :: $Thread = mysql_connect($host, $username, $passwd); // connect to server
} else
self :: $Thread = mysql_connect($host.":".(int) $port.":".$socket, $username, $passwd); // connect to server with port and socket settings
if (!self :: $Thread) {
exit ('<br/>Connect failed: '.mysql_error());
}
if (!mysql_select_db($dbname,self :: $Thread)) {
exit ("Can't use selected database : ".mysql_error());
}
}
public static function ServerVersion() {
return mysql_get_server_info(self :: $Thread);
}
public static function ServerInfo() {
return mysql_get_server_info(self :: $Thread);
}
public static function Test() {
printf("<br/>Host information: %s", mysql_get_host_info(self :: $Thread));
printf("<br/>Client Encoding: %s", mysql_client_encoding(self :: $Thread));
}
public static function EscapeString($string) {
return mysql_real_escape_string($string,self :: $Thread);
}
public static function SelectDB($dbname) {
return mysql_select_db($dbname, self :: $Thread);
}
public static function Query($query) {
if (!self :: $result = mysql_query($query,self :: $Thread)) {
exit ("<p>You have error in your query: ".$query."</p>");
}
Debug :: add_report("SQL: ".$query, 0);
self :: $lastQuery = $query;
return self :: $result;
}
public static function NumRows($result = null) {
if (isset ($result))
self :: $result = $result;
return mysql_num_rows(self :: $result);
}
public static function NumFields($result = null) {
if (isset ($result))
self :: $result = $result;
return mysql_num_fields(self :: $result);
}
public static function FetchRow($result = null) {
if (isset ($result))
self :: $result = $result;
return mysql_fetch_row(self :: $result);
}
public static function FetchObject($result = null) {
if (isset ($result))
self :: $result = $result;
return mysql_fetch_object(self :: $result);
}
public static function FetchArray($result = null) {
if (isset ($result))
self :: $result = $result;
return mysql_fetch_array(self :: $result,MYSQL_BOTH);
}
public static function Error() {
return mysql_error();
}
public static function Close() {
return mysql_close(self :: $Thread);
}
public static function CloseResult($result = null) {
if (isset ($result))
self :: $result = $result;
mysql_free_result(self :: $result);
}
}
?>
See more files for this project here
EliteCore Project is a PHP5.1/Javascript/AJAX/XHTML/CSS framework for creating WEB 2.0 applications and services.The basic open-source instalation can be also used as an interactive personal page or BLOG.This project uses the latest features available.
Project homepage:
http://sourceforge.net/projects/elitecore
Programming language(s): JavaScript,PHP,XML
License: cpl
mysql.php
mysqli.php