forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@pear: renamed DB_GETMODE_* to DB_FETCHMODE_*, added setFetchMode()
@ in DB_common to set the default mode, added some MySQL tests (Stig)
- Loading branch information
Showing
2 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,31 +94,32 @@ | |
define("DB_BINMODE_CONVERT", 3); | ||
|
||
|
||
|
||
/** | ||
* This is a special constant that tells DB the user hasn't specified | ||
* any particular get mode, so the default should be used. | ||
*/ | ||
define('DB_FETCHMODE_DEFAULT', 0); | ||
/** | ||
* Column data indexed by numbers, ordered from 0 and up | ||
*/ | ||
define('DB_GETMODE_ORDERED', 1); | ||
define('DB_FETCHMODE_ORDERED', 1); | ||
/** | ||
* Column data indexed by column names | ||
*/ | ||
define('DB_GETMODE_ASSOC', 2); | ||
define('DB_FETCHMODE_ASSOC', 2); | ||
/** | ||
* For multi-dimensional results: normally the first level of arrays | ||
* is the row number, and the second level indexed by column number or name. | ||
* DB_GETMODE_FLIPPED switches this order, so the first level of arrays | ||
* DB_FETCHMODE_FLIPPED switches this order, so the first level of arrays | ||
* is the column name, and the second level the row number. | ||
*/ | ||
define('DB_GETMODE_FLIPPED', 4); | ||
|
||
|
||
/** | ||
* This constant DB's default get mode. It is possible to override by | ||
* defining in your scripts before including DB. | ||
*/ | ||
if (!defined('DB_GETMODE_DEFAULT')) { | ||
define('DB_GETMODE_DEFAULT', DB_GETMODE_ORDERED); | ||
} | ||
define('DB_FETCHMODE_FLIPPED', 4); | ||
|
||
/* for compatibility */ | ||
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); | ||
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); | ||
define('DB_GETMODE_FLIPPED', DB_FETCHMODE_FLIPPED); | ||
|
||
/** | ||
* The main "DB" class is simply a container class with some static | ||
|
@@ -141,7 +142,7 @@ | |
* connections, the object returned is an instance of this | ||
* class. | ||
* | ||
* @version 1.00 | ||
* @version 2 | ||
* @author Stig Bakken <[email protected]> | ||
* @since PHP 4.0 | ||
*/ | ||
|
@@ -199,7 +200,7 @@ function &connect($dsn, $persistent = false) { | |
* @return int the DB API version number | ||
*/ | ||
function apiVersion() { | ||
return 1; | ||
return 2; | ||
} | ||
|
||
/** | ||
|
@@ -405,8 +406,11 @@ function DB_result(&$dbh, $result) { | |
* Fetch and return a row of data. | ||
* @return array a row of data, or false on error | ||
*/ | ||
function fetchRow($getmode = DB_GETMODE_DEFAULT) { | ||
return $this->dbh->fetchRow($this->result, $getmode); | ||
function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT) { | ||
if ($fetchmode == DB_FETCHMODE_DEFAULT) { | ||
$fetchmode = $this->dbh->fetchmode; | ||
} | ||
return $this->dbh->fetchRow($this->result, $fetchmode); | ||
} | ||
|
||
/** | ||
|
@@ -415,8 +419,11 @@ function fetchRow($getmode = DB_GETMODE_DEFAULT) { | |
* @param $arr reference to data array | ||
* @return int error code | ||
*/ | ||
function fetchInto(&$arr, $getmode = DB_GETMODE_DEFAULT) { | ||
return $this->dbh->fetchInto($this->result, $arr, $getmode); | ||
function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT) { | ||
if ($fetchmode == DB_FETCHMODE_DEFAULT) { | ||
$fetchmode = $this->dbh->fetchmode; | ||
} | ||
return $this->dbh->fetchInto($this->result, $arr, $fetchmode); | ||
} | ||
|
||
/** | ||
|
@@ -442,6 +449,14 @@ function free() { | |
} | ||
} | ||
|
||
/* | ||
* DB_Error TODO: | ||
* | ||
* - needs a way of storing queries (useful for debugging query syntax | ||
* errors) | ||
* | ||
*/ | ||
|
||
/** | ||
* DB_Error implements a class for reporting portable database error | ||
* messages. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters