不调用my.ini里的默认设置.......... 代码: <? class dbbase_sql { var $Host = ''; var $Database = ''; var $User = ''; var $Password = ''; var $Link_ID = 0; var $Query_ID = 0; var $Record = array (); var $Row = null; var $Errno = 0; var $Error = ''; var $Auto_free = 0; var $Auto_commit = 0; function connect () { if ((0 == $this->Link_ID)) { $this->Link_ID = mysql_connect ($this->Host, $this->User, $this->Password); if (!$this->Link_ID) { $this->halt (('Link-ID == false, connect failed<br>'.mysql_error ())); } if (('5.0.1' < $this->getVersion ())) { mysql_query ('SET sql_mode=\'\'', $this->Link_ID); } if (!mysql_select_db ($this->Database, $this->Link_ID)) { $this->halt (('cannot use database '.$this->Database)); } if (defined ('MYSQL_CHARSET_NAME')) { mysql_query ((('SET NAMES \''.MYSQL_CHARSET_NAME).'\''), $this->Link_ID); } if (defined ('MYSQL_CHARSET')) { mysql_query (('SET CHARACTER SET '.MYSQL_CHARSET), $this->Link_ID); } if (defined ('MYSQL_COLLATION')) { mysql_query ((('SET collation_connection = \''.MYSQL_COLLATION).'\''), $this->Link_ID); } } } function getversion () { return mysql_get_server_info (); } function close () { if ((0 != $this->Link_ID)) { mysql_close ($this->Link_ID); } } function query ($Query_String) { global $query_count; global $debuging_info; global $totalsqltime; $this->connect (); if (function_exists ('shop_debuging')) { $start = getmicrotime (); } $this->Query_ID = mysql_query ($Query_String, $this->Link_ID); $this->Row = 0; $this->Errno = mysql_errno (); $this->Error = (($this->Database.':').mysql_error ()); if (function_exists ('shop_debuging')) { if (shop_debuging ()) { $query_count++; ($debuging_info .= (('SQL QUERY: '.$Query_String).'<br>')); ($totalsqltime += (getmicrotime () - $start)); ($debuging_info .= (('SQL Time: '.(getmicrotime () - $start)).'<br>')); } } if (!$this->Query_ID) { $this->halt (('Invalid SQL: '.$Query_String)); } return $this->Query_ID; } function next_record () { $this->Record = mysql_fetch_array ($this->Query_ID); ($this->Row += 1); $stat = is_array ($this->Record); if ((!$stat AND $this->Auto_free)) { mysql_free_result ($this->Query_ID); $this->Query_ID = 0; } return $stat; } function seek ($pos) { $status = mysql_data_seek ($this->Query_ID, $pos); if ($status) { $this->Row = $pos; } return null; } function metadata ($table) { $count = 0; $id = 0; $res = array (); $this->connect (); $id = mysql_list_fields ($this->Database, $table); if (($id < 0)) { $this->halt ('Metadata query failed.'); } $count = mysql_num_fields ($id); for ($i = 0; ($i < $count); $i++) { $res[$i]['table'] = mysql_field_table ($id, $i); $res[$i]['name'] = mysql_field_name ($id, $i); $res[$i]['type'] = mysql_field_type ($id, $i); $res[$i]['len'] = mysql_field_len ($id, $i); $res[$i]['flags'] = mysql_field_flags ($id, $i); $res['meta'][$res[$i]['name']] = $i; $res['num_fields'] = $count; } mysql_free_result ($id); return $res; } function affected_rows () { return mysql_affected_rows ($this->Link_ID); } function num_rows () { return mysql_num_rows ($this->Query_ID); } function num_fields () { return mysql_num_fields ($this->Query_ID); } function nf () { return $this->num_rows (); } function np () { print $this->num_rows (); } function f ($Name) { return $this->Record[$Name]; } function p ($Name) { print $this->Record[$Name]; } function pos () { return $this->Row; } function instid () { return mysql_insert_id ($this->Link_ID); } function errorno () { return mysql_errno ($this->Link_ID); } function halt ($msg) { $showerror = false; if (defined ('SYS_DEBUGING')) { if (SYS_DEBUGING) { $showerror = true; } } if ($showerror) { printf ('</td></tr></table><b>Database error:</b> %s<br> ', $msg); printf ('<b>MySQL Error</b>: %s (%s)<br> ', $this->Errno, $this->Error); exit ('Session halted.'); } else { exit ('<b>Database error,Session halted.</b>'); } } } class yq_sql extends dbbase_sql { var $Host = ''; var $Database = ''; var $User = ''; var $Password = ''; var $Link_ID = 0; var $Query_ID = 0; var $Record = array (); var $Row = null; var $Errno = 0; var $Error = ''; var $Auto_free = 0; var $Auto_commit = 0; function yq_sql () { global $dbHost; global $dbName; global $dbUser; global $dbPass; $this->Host = $dbHost; $this->Database = $dbName; $this->User = $dbUser; $this->Password = $dbPass; } function free_result () { return mysql_free_result ($this->Query_ID); } function rollback () { return 1; } function commit () { return 1; } function autocommit ($onezero) { return 1; } function insert_id ($col = '', $tbl = '', $qual = '') { return mysql_insert_id ($this->Link_ID); } } $pub_inc = 1; $databaseeng = 'mysql'; $dialect = ''; ?>