cox Tue Jun 18 20:41:06 2002 EDT
Modified files:
/pear/DB/DB mysql.php
Log:
Allow connect/use the MySQL driver without specifying any database
Index: pear/DB/DB/mysql.php
diff -u pear/DB/DB/mysql.php:1.4 pear/DB/DB/mysql.php:1.5
--- pear/DB/DB/mysql.php:1.4 Thu May 23 05:14:37 2002
+++ pear/DB/DB/mysql.php Tue Jun 18 20:41:06 2002
@@ -16,7 +16,7 @@
// | Author: Stig Bakken <ssb@xxxxxxx> |
// +----------------------------------------------------------------------+
//
-// $Id: mysql.php,v 1.4 2002/05/23 09:14:37 cox Exp $
+// $Id: mysql.php,v 1.5 2002/06/19 00:41:06 cox Exp $
//
// Database independent query interface definition for PHP's MySQL
// extension.
@@ -203,8 +203,10 @@
$ismanip = DB::isManip($query);
$this->last_query = $query;
$query = $this->modifyQuery($query);
- if (!@mysql_select_db($this->_db, $this->connection)) {
- return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ if ($this->_db) {
+ if (!@mysql_select_db($this->_db, $this->connection)) {
+ return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ }
}
if (!$this->autocommit && $ismanip) {
if ($this->transaction_opcount == 0) {
@@ -413,8 +415,10 @@
function commit()
{
if ($this->transaction_opcount > 0) {
- if (!@mysql_select_db($this->_db, $this->connection)) {
- return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ if ($this->_db) {
+ if (!@mysql_select_db($this->_db, $this->connection)) {
+ return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ }
}
$result = @mysql_query('COMMIT', $this->connection);
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection);
@@ -435,8 +439,10 @@
function rollback()
{
if ($this->transaction_opcount > 0) {
- if (!@mysql_select_db($this->_db, $this->connection)) {
- return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ if ($this->_db) {
+ if (!@mysql_select_db($this->_db, $this->connection)) {
+ return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ }
}
$result = @mysql_query('ROLLBACK', $this->connection);
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection);
@@ -504,9 +510,6 @@
function nextId($seq_name, $ondemand = true)
{
$seqname = $this->getSequenceName($seq_name);
- if (!@mysql_select_db($this->_db, $this->connection)) {
- return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
- }
do {
$repeat = 0;
$this->pushErrorHandling(PEAR_ERROR_RETURN);
@@ -685,8 +688,7 @@
function modifyLimitQuery($query, $from, $count)
{
- $query = $query . " LIMIT $from, $count";
- return $query;
+ return $query . " LIMIT $from, $count";
}
// }}}
@@ -847,4 +849,4 @@
// binmode
}
-?>
+?>
\ No newline at end of file
--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|