---------- Php debug ----------
Server = localhost; DataBase = mysql; UserID = root; PassWord = 123456
Resource (5) of type (mysql result)
Output completed (1 sec consumed)-Normal Termination
<? Php
Class DBCLS
{
// Debug switch
Var $ debug = true;
// Debuginfo error message and debugging information
Var $ debuginfo = "debug informations: rn ";
// Db_server MySQL host address
Var $ db_server;
// Db_name database name
Var $ db_name;
// Db_user database username
Var $ db_user;
// Db_passwd password
Var $ db_passwd;
// Db_links database connection
Var $ db_link;
// Db_query_ SQL SQL statement
Var $ db_query_ SQL = "show tables ";
// Db_recordset result set, record set
Var $ db_recordset;
// Ready switch
Var $ conntstr_ready = false;
Var $ link_ready = false;
Var $ db_ready = false;
// Set or return Connection String, or set the Connection String
Function connection_string ($ connstr = "")
{
If ("" = $ connstr)
{
// If no parameter is input, the existing connection characters are returned.
Return "Server = ". $ this-> db_server. "; DataBase = ". $ this-> db_name. "; UserID = ". $ this-> db_user. "; PassWord = ". $ this-> db_passwd;
}
Else
{
// Otherwise, parse the connection character and initialize the variable
Preg_match_all ("| ([a-zA-Z0-9] *) = ([a-zA-Z0-9] *); * |", $ connstr, $ tmparr, PREG_PATTERN_ORDER );
$ This-> db_server = (strtolower ($ tmparr [1] [0]) = "server ")? $ Tmparr [2] [0]: "";
$ This-> db_name = (strtolower ($ tmparr [1] [1]) = "database ")? $ Tmparr [2] [1]: "";
$ This-> db_user = (strtolower ($ tmparr [1] [2]) = "userid ")? $ Tmparr [2] [2]: "";
$ This-> db_passwd = (strtolower ($ tmparr [1] [3]) = "password ")? $ Tmparr [2] [3]: "";
// Var_dump ($ tmparr );
If ("" = $ this-> db_server or "" = $ this-> db_name or "" = $ this-> db_user or "" = $ this-> db_passwd)
$ This-> conntstr_ready = false; // if more than one of the variables is assigned an empty string "", it is not ready.
Else
$ This-> conntstr_ready = true;
Return $ this-> conntstr_ready;
}
}
// Connect to the database and return the connection object
Function connect ()
{
If (! $ This-> conntstr_ready)
{