1 | <?php
|
---|
2 |
|
---|
3 |
|
---|
4 | /*
|
---|
5 | V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
|
---|
6 | Released under both BSD license and Lesser GPL library license.
|
---|
7 | Whenever there is any discrepancy between the two licenses,
|
---|
8 | the BSD license will take precedence.
|
---|
9 | Set tabs to 8.
|
---|
10 |
|
---|
11 | */
|
---|
12 |
|
---|
13 | class ADODB_pdo_oci extends ADODB_pdo_base {
|
---|
14 |
|
---|
15 | var $concat_operator='||';
|
---|
16 | var $sysDate = "TRUNC(SYSDATE)";
|
---|
17 | var $sysTimeStamp = 'SYSDATE';
|
---|
18 | var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
|
---|
19 | var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
|
---|
20 | var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')";
|
---|
21 | var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno";
|
---|
22 |
|
---|
23 | var $_initdate = true;
|
---|
24 | var $_hasdual = true;
|
---|
25 |
|
---|
26 | function _init($parentDriver)
|
---|
27 | {
|
---|
28 | $parentDriver->_bindInputArray = true;
|
---|
29 | $parentDriver->_nestedSQL = true;
|
---|
30 | if ($this->_initdate) {
|
---|
31 | $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | function &MetaTables($ttype=false,$showSchema=false,$mask=false)
|
---|
36 | {
|
---|
37 | if ($mask) {
|
---|
38 | $save = $this->metaTablesSQL;
|
---|
39 | $mask = $this->qstr(strtoupper($mask));
|
---|
40 | $this->metaTablesSQL .= " AND table_name like $mask";
|
---|
41 | }
|
---|
42 | $ret =& ADOConnection::MetaTables($ttype,$showSchema);
|
---|
43 |
|
---|
44 | if ($mask) {
|
---|
45 | $this->metaTablesSQL = $save;
|
---|
46 | }
|
---|
47 | return $ret;
|
---|
48 | }
|
---|
49 |
|
---|
50 | function &MetaColumns($table)
|
---|
51 | {
|
---|
52 | global $ADODB_FETCH_MODE;
|
---|
53 |
|
---|
54 | $false = false;
|
---|
55 | $save = $ADODB_FETCH_MODE;
|
---|
56 | $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
---|
57 | if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
---|
58 |
|
---|
59 | $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
|
---|
60 |
|
---|
61 | if (isset($savem)) $this->SetFetchMode($savem);
|
---|
62 | $ADODB_FETCH_MODE = $save;
|
---|
63 | if (!$rs) {
|
---|
64 | return $false;
|
---|
65 | }
|
---|
66 | $retarr = array();
|
---|
67 | while (!$rs->EOF) { //print_r($rs->fields);
|
---|
68 | $fld = new ADOFieldObject();
|
---|
69 | $fld->name = $rs->fields[0];
|
---|
70 | $fld->type = $rs->fields[1];
|
---|
71 | $fld->max_length = $rs->fields[2];
|
---|
72 | $fld->scale = $rs->fields[3];
|
---|
73 | if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
|
---|
74 | $fld->type ='INT';
|
---|
75 | $fld->max_length = $rs->fields[4];
|
---|
76 | }
|
---|
77 | $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
|
---|
78 | $fld->binary = (strpos($fld->type,'BLOB') !== false);
|
---|
79 | $fld->default_value = $rs->fields[6];
|
---|
80 |
|
---|
81 | if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
|
---|
82 | else $retarr[strtoupper($fld->name)] = $fld;
|
---|
83 | $rs->MoveNext();
|
---|
84 | }
|
---|
85 | $rs->Close();
|
---|
86 | if (empty($retarr))
|
---|
87 | return $false;
|
---|
88 | else
|
---|
89 | return $retarr;
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | ?> |
---|