cvs: pear /DB/DB mssql.php

From: Date: Thu, 23 May 2002 09:09:39 +0000
Subject: cvs: pear /DB/DB mssql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4045@lists.php.net to get a copy of this message
cox Thu May 23 05:09:39 2002 EDT Modified files: /pear/DB/DB mssql.php Log: Fix support for multiple connections in the same script Index: pear/DB/DB/mssql.php diff -u pear/DB/DB/mssql.php:1.3 pear/DB/DB/mssql.php:1.4 --- pear/DB/DB/mssql.php:1.3 Thu May 9 08:29:53 2002 +++ pear/DB/DB/mssql.php Thu May 23 05:09:39 2002 @@ -16,7 +16,7 @@ // | Author: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.3 2002/05/09 12:29:53 ssb Exp $ +// $Id: mssql.php,v 1.4 2002/05/23 09:09:39 cox Exp $ // // Database independent query interface definition for PHP's Microsoft SQL Server // extension. @@ -32,6 +32,7 @@ var $prepare_types = array(); var $transaction_opcount = 0; var $autocommit = true; + var $_db = null; function DB_mssql() { @@ -80,6 +81,7 @@ return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, mssql_get_last_message()); } + $this->_db = $dsninfo['database']; } $this->connection = $conn; return DB_OK; @@ -96,6 +98,9 @@ { $ismanip = DB::isManip($query); $this->last_query = $query; + if (!@mssql_select_db($this->_db, $this->connection)) { + return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED); + } $query = $this->modifyQuery($query); if (!$this->autocommit && $ismanip) { if ($this->transaction_opcount == 0) { @@ -220,6 +225,9 @@ function commit() { if ($this->transaction_opcount > 0) { + if (!@mssql_select_db($this->_db, $this->connection)) { + return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED); + } $result = @mssql_query('COMMIT TRAN', $this->connection); $this->transaction_opcount = 0; if (!$result) { @@ -238,6 +246,9 @@ function rollback() { if ($this->transaction_opcount > 0) { + if (!@mssql_select_db($this->_db, $this->connection)) { + return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED); + } $result = @mssql_query('ROLLBACK TRAN', $this->connection); $this->transaction_opcount = 0; if (!$result) { @@ -293,6 +304,9 @@ function nextId($seq_name, $ondemand = true) { $seqname = $this->getSequenceName($seq_name); + if (!@mssql_select_db($this->_db, $this->connection)) { + return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED); + } $repeat = 0; do { $this->pushErrorHandling(PEAR_ERROR_RETURN); @@ -358,8 +372,7 @@ return $this->raiseError($code); } } - return $this->raiseError($code, null, null, null, - mssql_get_last_message()); + return $this->raiseError($code, null, null, null, mssql_get_last_message()); } /** @@ -423,6 +436,9 @@ // table without a resultset if (is_string($result)) { + if (!@mssql_select_db($this->_db, $this->connection)) { + return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED); + } $id = mssql_query("SELECT * FROM $result", $this->connection); if (empty($id)) { return $this->mssqlRaiseError();

« previous php.pear.cvs (#4045) next »