|
PHP 的 MySQL 操作类,跟手册上的函数一样用,但是更方便了。多说无益,看了就知道了。(2) $this->selectDB($DBName); } } function splitDSN($dsn){ //$dsn = "数据库类型名称://入口帐号:入口密码@数据库主机名:端口号/数据库名/是否总是打开新的连接"; //$dsn = "MySQL://Dummy:123@localhost:3306/tetx/false"; $dsn = preg_split("/[:\/@]/", $dsn); $DBTpye = ''; $DBHost = ''; $DBPort = ''; $DBUser = ''; $DBPswd = ''; $DBName = ''; $DBNewLink = false; $DBTpye = $dsn[0]; $DBHost = $dsn[5]; $DBPort = $dsn[6]; $DBUser = $dsn[3]; $DBPswd = $dsn[4]; $DBName = $dsn[7]; $DBNewLink = $dsn[8]; return array($DBTpye, $DBHost, $DBPort, $DBUser, $DBPswd, $DBName, $DBNewLink); } function affectedRows(){ /* 取得前一次 MySQL 操作所影响的记录行数 */ return mysql_affected_rows($this->LinkId); } function changeUser($user, $passWord){ /* 改变活动连接中登录的用户 */ return mysql_change_user($user, $password, $this->DBName, $this->LinkId); } function clientEncoding(){ /* 返回字符集的名称 */ return mysql_client_encoding($this->LinkId); } function close(){ /* 关闭 MySQL 连接 */ $close = mysql_close($this->LinkId); $this->LinkId = NULL; $this->Result = NULL; $this->Record = NULL; return $close; } function connect($DBHost = '', $DBUser = '', $DBPswd = '', $newLink = false){//, int client_flags){ /* 打开一个到 MySQL 服务器的连接 */ $connect = @mysql_connect(empty($DBHost)?$this->DBHost:$DBHost, empty($DBUser)?$this->DBUser:$DBUser, empty($DBPswd)?$this->DBPswd:$DBPswd, $newLink);
|