[016aff]: adminer / drivers / oracle.inc.php  Maximize  Restore  History

Download this file

335 lines (282 with data), 8.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
$possible_drivers[] = "OCI8";
$possible_drivers[] = "PDO_OCI";
if (extension_loaded("oci8") || extension_loaded("pdo_oci")) {
$drivers["oracle"] = "Oracle";
}
if (isset($_GET["oracle"])) {
define("DRIVER", "oracle");
if (extension_loaded("oci8")) {
class Min_DB {
var $extension = "oci8", $_link, $_result, $server_info, $affected_rows, $error;
function _error($errno, $error) {
if (ini_bool("html_errors")) {
$error = html_entity_decode(strip_tags($error));
}
$error = ereg_replace('^[^:]*: ', '', $error);
$this->error = $error;
}
function connect($server, $username, $password) {
$this->_link = @oci_new_connect($username, $password, $server); //! AL32UTF8
if ($this->_link) {
$this->server_info = oci_server_version($this->_link);
return true;
}
$error = oci_error();
$this->error = $error["message"];
return false;
}
function quote($string) {
return "'" . str_replace("'", "''", $string) . "'";
}
function select_db($database) {
return true;
}
function query($query, $unbuffered = false) {
$result = oci_parse($this->_link, $query);
if (!$result) {
$error = oci_error($this->_link);
$this->error = $error["message"];
return false;
}
set_error_handler(array($this, '_error'));
$return = @oci_execute($result);
restore_error_handler();
if ($return) {
if (oci_num_fields($result)) {
return new Min_Result($result);
}
$this->affected_rows = oci_num_rows($result);
}
return $return;
}
function multi_query($query) {
return $this->_result = $this->query($query);
}
function store_result() {
return $this->_result;
}
function next_result() {
return false;
}
function result($query, $field = 1) {
$result = $this->query($query);
if (!is_object($result) || !oci_fetch($result->_result)) {
return false;
}
return oci_result($result->_result, $field);
}
}
class Min_Result {
var $_result, $_offset = 1, $num_rows;
function Min_Result($result) {
$this->_result = $result;
$this->num_rows = -1; // all results unbuffered
}
function fetch_assoc() {
return oci_fetch_assoc($this->_result);
}
function fetch_row() {
return oci_fetch_row($this->_result);
}
function fetch_field() {
$column = $this->_offset++;
$return = new stdClass;
$return->name = oci_field_name($this->_result, $column);
$return->orgname = $return->name;
$return->type = oci_field_type($this->_result, $column);
$return->charsetnr = (ereg("raw|blob|bfile", $return->type) ? 63 : 0); // 63 - binary
return $return;
}
function __destruct() {
oci_free_statement($this->_result);
}
}
} elseif (extension_loaded("pdo_oci")) {
class Min_DB extends Min_PDO {
var $extension = "PDO_OCI";
function connect($server, $username, $password) {
}
function select_db($database) {
}
}
}
function idf_escape($idf) {
return '"' . str_replace('"', '""', $idf) . '"';
}
function table($idf) {
return idf_escape($idf);
}
function connect() {
global $adminer;
$connection = new Min_DB;
$credentials = $adminer->credentials();
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
return $connection;
}
return $connection->error;
}
function get_databases() {
return get_vals("SELECT tablespace_name FROM user_tablespaces");
}
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
return " $query$where" . (isset($limit) ? ($where ? " AND" : $separator . "WHERE") . ($offset ? " rownum > $offset AND" : "") . " rownum <= " . ($limit + $offset) : "");
}
function limit1($query, $where) {
return " $query$where";
}
function db_collation($db, $collations) {
//!
}
function engines() {
return array();
}
function logged_user() {
global $connection;
return $connection->result("SELECT USER FROM DUAL");
}
function tables_list() {
global $connection;
return get_key_vals("SELECT table_name FROM all_tables WHERE tablespace_name = " . $connection->quote(DB)); //! views
}
function count_tables($databases) {
return array();
}
function table_status($name = "") {
global $connection;
$return = array();
$result = $connection->query('SELECT table_name "Name" FROM all_tables' . ($name != "" ? ' WHERE table_name = ' . $connection->quote($name) : ''));
while ($row = $result->fetch_assoc()) {
if ($name != "") {
return $row;
}
$return[$row["Name"]] = $row;
}
return $return;
}
function fk_support($table_status) {
return true;
}
function fields($table) {
global $connection;
$return = array();
$result = $connection->query("SELECT * FROM all_tab_columns WHERE table_name = " . $connection->quote($table) . " ORDER BY column_id");
if ($result) {
while ($row = $result->fetch_assoc()) {
$type = $row["DATA_TYPE"];
$length = "$row[DATA_PRECISION],$row[DATA_SCALE]";
if ($length == ",") {
$length = $row["DATA_LENGTH"];
} //! int
$return[$row["COLUMN_NAME"]] = array(
"field" => $row["COLUMN_NAME"],
"full_type" => $type . ($length ? "($length)" : ""),
"type" => $type,
"length" => $length,
"default" => $row["DATA_DEFAULT"],
"null" => ($row["NULLABLE"] == "Y"),
//! "auto_increment" => false,
"collation" => $row["CHARACTER_SET_NAME"],
"privileges" => array("insert" => 1, "select" => 1, "update" => 1),
//! "comment" => $row["Comment"],
//! "primary" => ($row["Key"] == "PRI"),
);
}
}
return $return;
}
function indexes($table, $connection2 = null) {
return array(); //!
}
function collations() {
return array(); //!
}
function information_schema($db) {
return false;
}
function error() {
global $connection;
return h($connection->error); //! highlight sqltext from offset
}
function exact_value($val) {
global $connection;
return $connection->quote($val);
}
function explain($connection, $query) {
//!
}
function foreign_keys($table) {
return array(); //!
}
function truncate_tables($tables) {
foreach ($tables as $table) {
if (!queries("TRUNCATE TABLE " . table($table))) {
return false;
}
}
return true;
}
function drop_views($views) {
foreach ($views as $table) {
if (!queries("DROP VIEW " . table($table))) {
return false;
}
}
return true;
}
function drop_tables($tables) {
foreach ($tables as $table) {
if (!queries("DROP TABLE " . table($table))) {
return false;
}
}
return true;
}
function begin() {
return true; // automatic start
}
function insert_into($table, $set) {
return queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")"); //! no columns
}
function last_id() {
return 0; //!
}
function schemas() {
return array();
}
function get_schema() {
return "";
}
function set_schema($scheme) {
return true;
}
function support($feature) {
return false; //!
}
$jush = "oracle";
$types = array();
$structured_types = array();
foreach (array(
lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21),
lang('Date and time') => array("date" => 10, "timestamp" => 29, "interval year to month" => 12, "interval day to second" => 28), //! year(), day() to second()
lang('Strings') => array("char" => 2000, "varchar2" => 4000, "nchar" => 2000, "nvarchar2" => 4000, "clob" => 4294967295, "nclob" => 4294967295),
lang('Binary') => array("raw" => 2000, "long raw" => 2147483648, "blob" => 4294967295, "bfile" => 4294967296),
) as $key => $val) {
$types += $val;
$structured_types[$key] = array_keys($val);
}
$unsigned = array();
$operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL");
$functions = array("length", "lower", "round", "upper");
$grouping = array("avg", "count", "count distinct", "max", "min", "sum");
$edit_functions = array(
array( //! no parentheses
"date" => "current_date",
"timestamp" => "current_timestamp",
), array(
"number|float|double" => "+/-",
"date|timestamp" => "+ interval/- interval",
"char|clob" => "||",
)
);
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks