From 84d068df8b90ebbf2fbadcc560b6c9aa3cbef401 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 20 May 2010 17:35:30 +0200 Subject: [PATCH] Oracle select support --- adminer/drivers/oracle.inc.php | 26 ++++++++++++++++++++------ todo.txt | 3 +++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 19c6e0fb..87a45eb0 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -86,12 +86,21 @@ if (isset($_GET["oracle"])) { $this->num_rows = -1; // all results unbuffered } + function _convert($row) { + foreach ((array) $row as $key => $val) { + if (is_a($val, 'OCI-Lob')) { + $row[$key] = $val->load(); + } + } + return $row; + } + function fetch_assoc() { - return oci_fetch_assoc($this->_result); + return $this->_convert(oci_fetch_assoc($this->_result)); } function fetch_row() { - return oci_fetch_row($this->_result); + return $this->_convert(oci_fetch_row($this->_result)); } function fetch_field() { @@ -189,7 +198,7 @@ if (isset($_GET["oracle"])) { } function fk_support($table_status) { - return false; //! + return true; } function fields($table) { @@ -252,7 +261,7 @@ if (isset($_GET["oracle"])) { foreach ($fields as $field) { $val = $field[1]; if ($val && $field[0] != "" && idf_escape($field[0]) != $val[0]) { - queries("ALTER TABLE " . table($name) . " RENAME COLUMN " . idf_escape($field[0]) . " TO $val[0]"); + queries("ALTER TABLE " . table($table) . " RENAME COLUMN " . idf_escape($field[0]) . " TO $val[0]"); } if ($val) { $alter[] = ($table != "" ? ($field[0] != "" ? "MODIFY (" : "ADD (") : " ") . implode($val) . ($table != "" ? ")" : ""); //! error with name change only @@ -263,11 +272,16 @@ if (isset($_GET["oracle"])) { if ($table == "") { return queries("CREATE TABLE " . table($name) . " (\n" . implode(",\n", $alter) . "\n)"); } - return (!$alter || queries("ALTER TABLE " . table($name) . "\n" . implode("\n", $alter))) - && (!$drop || queries("ALTER TABLE " . table($name) . " DROP (" . implode(", ", $drop) . ")")) + return (!$alter || queries("ALTER TABLE " . table($table) . "\n" . implode("\n", $alter))) + && (!$drop || queries("ALTER TABLE " . table($table) . " DROP (" . implode(", ", $drop) . ")")) + && ($table == $name || queries("ALTER TABLE " . table($table) . " RENAME TO " . table($name))) ; } + function foreign_keys($table) { + return array(); //! + } + function truncate_tables($tables) { return apply_queries("TRUNCATE TABLE", $tables); } diff --git a/todo.txt b/todo.txt index d005bdcb..4143150e 100644 --- a/todo.txt +++ b/todo.txt @@ -44,3 +44,6 @@ Non UTF-8 character sets Rename by sp_rename Detection of table collation PDO driver with seek + +Oracle: +clob comparable with string