From 6cca965e8f7223d67e2eafed1c9d2127cf328347 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 14 Jan 2006 20:20:57 +0000 Subject: [PATCH] Allow fetching of enumerated rows instead of assoc --- db.php | 6 ++++-- db_mysql.php | 1 + db_mysqli.php | 1 + db_postgresql.php | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/db.php b/db.php index f5ef49d..7355c47 100644 --- a/db.php +++ b/db.php @@ -113,6 +113,7 @@ class DB_Abstract 'error_str' => '%link', 'escape_string' => '%link %string', 'fetch_assoc' => '%result', + 'fetch_row' => '%result', 'fetch_object' => '%result', 'free_result' => '%result', 'insert_id' => '%link', @@ -252,12 +253,13 @@ class DB_Abstract * @access public * * @param integer Result + * @param bool Return an associative array? * * @return array A row of the query result */ - function fetch_array($result) + function fetch_array($result, $assoc = true) { - return call_user_func($this->commands['fetch_assoc'], $result); + return call_user_func($this->commands[ ($assoc ? 'fetch_assoc' : 'fetch_row') ], $result); } // ################################################################### diff --git a/db_mysql.php b/db_mysql.php index 1f13c3a..64d1d61 100644 --- a/db_mysql.php +++ b/db_mysql.php @@ -55,6 +55,7 @@ class DB_MySQL extends DB_Abstract 'error_str' => 'mysql_error', 'escape_string' => '$this->command_mysql_escape_string', 'fetch_assoc' => 'mysql_fetch_assoc', + 'fetch_row' => 'mysql_fetch_row', 'fetch_object' => 'mysql_fetch_object', 'free_result' => 'mysql_free_result', 'insert_id' => 'mysql_insert_id', diff --git a/db_mysqli.php b/db_mysqli.php index 07ee188..b02a201 100644 --- a/db_mysqli.php +++ b/db_mysqli.php @@ -55,6 +55,7 @@ class DB_MySQLi extends DB_Abstract 'error_str' => 'mysqli_error', 'escape_string' => 'mysqli_real_escape_string', 'fetch_assoc' => 'mysqli_fetch_assoc', + 'fetch_row' => 'mysqli_fetch_row', 'fetch_object' => 'mysqli_fetch_object', 'free_result' => 'mysqli_free_result', 'insert_id' => 'mysqli_insert_id', diff --git a/db_postgresql.php b/db_postgresql.php index b6b9e20..f87749a 100644 --- a/db_postgresql.php +++ b/db_postgresql.php @@ -55,6 +55,7 @@ class DB_PostgreSQL extends DB_Abstract 'error_str' => '$this->command_error_str', 'escape_string' => '$this->command_pg_escape_string', 'fetch_assoc' => 'pg_fetch_assoc', + 'fetch_row' => 'pg_fetch_row', 'fetch_object' => 'pg_fetch_object', 'free_result' => 'pg_free_result', 'insert_id' => '%link', // how do we support this...? -- 2.22.5