<?php include_once '../doc-typo3-funcs.php'; $doxygen_vars = array( "title" => "TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/drivers/adodb-oci8po.inc.php Source File", "datetime" => "Sat Dec 2 19:22:26 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?> <!-- Generated by Doxygen 1.4.6 --> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul></div> <div class="nav"> <a class="el" href="dir_c8daf1ad746050abf985cc546c89e248.html">typo3_src-4.0.1</a> » <a class="el" href="dir_18071ae4545d8b3e0364d30c0659c74a.html">typo3</a> » <a class="el" href="dir_57bf1ed8249c1fd5b014486d01bcb27a.html">sysext</a> » <a class="el" href="dir_e81b1679233d44b74aed493d6fe8e943.html">adodb</a> » <a class="el" href="dir_1f526b87ad011e46f671ba6e798564e1.html">adodb</a> » <a class="el" href="dir_1e0b3ded0d6f913dc09ca6aa6ebd4980.html">drivers</a></div> <h1>adodb-oci8po.inc.php</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <?php <a name="l00002"></a>00002 <span class="comment">/*</span> <a name="l00003"></a>00003 <span class="comment">V4.90 8 June 2006 (c) 2000-2006 John Lim. All rights reserved.</span> <a name="l00004"></a>00004 <span class="comment"> Released under both BSD license and Lesser GPL library license. </span> <a name="l00005"></a>00005 <span class="comment"> Whenever there is any discrepancy between the two licenses, </span> <a name="l00006"></a>00006 <span class="comment"> the BSD license will take precedence.</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> Latest version is available at http://adodb.sourceforge.net</span> <a name="l00009"></a>00009 <span class="comment"> </span> <a name="l00010"></a>00010 <span class="comment"> Portable version of oci8 driver, to make it more similar to other database drivers.</span> <a name="l00011"></a>00011 <span class="comment"> The main differences are</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> 1. that the OCI_ASSOC names are in lowercase instead of uppercase.</span> <a name="l00014"></a>00014 <span class="comment"> 2. bind variables are mapped using ? instead of :<bindvar></span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment"> Should some emulation of RecordCount() be implemented?</span> <a name="l00017"></a>00017 <span class="comment"> </span> <a name="l00018"></a>00018 <span class="comment">*/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="comment">// security - hide paths</span> <a name="l00021"></a>00021 <span class="keywordflow">if</span> (!defined('ADODB_DIR')) die(); <a name="l00022"></a>00022 <a name="l00023"></a>00023 include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); <a name="l00024"></a>00024 <a name="l00025"></a><a class="code" href="classADODB__oci8po.html">00025</a> <span class="keyword">class </span><a class="code" href="classADODB__oci8po.html">ADODB_oci8po</a> <span class="keyword">extends</span> <a class="code" href="classADODB__oci8.html">ADODB_oci8</a> { <a name="l00026"></a><a class="code" href="classADODB__oci8po.html#b61088ddb9a87f66b5dd5b974f990b22">00026</a> var <a class="code" href="classADODB__oci8po.html#b61088ddb9a87f66b5dd5b974f990b22">$databaseType</a> = 'oci8po'; <a name="l00027"></a><a class="code" href="classADODB__oci8po.html#3ebcdceac8826e2beaa71fca9fa7ca42">00027</a> var <a class="code" href="classADODB__oci8po.html#3ebcdceac8826e2beaa71fca9fa7ca42">$dataProvider</a> = 'oci8'; <a name="l00028"></a><a class="code" href="classADODB__oci8po.html#5e10c7d809e5231c47a111578f5b7cf7">00028</a> var <a class="code" href="classADODB__oci8po.html#5e10c7d809e5231c47a111578f5b7cf7">$metaColumnsSQL</a> = <span class="stringliteral">"select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"</span>; <span class="comment">//changed by smondino@users.sourceforge. net</span> <a name="l00029"></a><a class="code" href="classADODB__oci8po.html#66657a731b14d8dbefa2813e28c373fe">00029</a> var <a class="code" href="classADODB__oci8po.html#66657a731b14d8dbefa2813e28c373fe">$metaTablesSQL</a> = <span class="stringliteral">"select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"</span>; <a name="l00030"></a>00030 <a name="l00031"></a><a class="code" href="classADODB__oci8po.html#8d5f094d6a15f832b22cddb866d752fb">00031</a> function <a class="code" href="classADODB__oci8po.html#8d5f094d6a15f832b22cddb866d752fb">ADODB_oci8po</a>() <a name="l00032"></a>00032 { <a name="l00033"></a>00033 $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; <a name="l00034"></a>00034 <span class="preprocessor"> # oci8po does not support adodb extension: adodb_movenext()</span> <a name="l00035"></a>00035 <span class="preprocessor"></span> } <a name="l00036"></a>00036 <a name="l00037"></a><a class="code" href="classADODB__oci8po.html#bd1ff802e497d7dfdf3c7eacc48165c2">00037</a> function <a class="code" href="classADODB__oci8po.html#bd1ff802e497d7dfdf3c7eacc48165c2">Param</a>($name) <a name="l00038"></a>00038 { <a name="l00039"></a>00039 <span class="keywordflow">return</span> <span class="charliteral">'?'</span>; <a name="l00040"></a>00040 } <a name="l00041"></a>00041 <a name="l00042"></a><a class="code" href="classADODB__oci8po.html#cf6b9bc8c22106aaa75007d861926123">00042</a> function <a class="code" href="classADODB__oci8po.html#cf6b9bc8c22106aaa75007d861926123">Prepare</a>($sql,$cursor=<span class="keyword">false</span>) <a name="l00043"></a>00043 { <a name="l00044"></a>00044 $sqlarr = explode(<span class="charliteral">'?'</span>,$sql); <a name="l00045"></a>00045 $sql = $sqlarr[0]; <a name="l00046"></a>00046 <span class="keywordflow">for</span> ($i = 1, $max = <span class="keyword">sizeof</span>($sqlarr); $i < $max; $i++) { <a name="l00047"></a>00047 $sql .= <span class="charliteral">':'</span>.($i-1) . $sqlarr[$i]; <a name="l00048"></a>00048 } <a name="l00049"></a>00049 <span class="keywordflow">return</span> <a class="code" href="classADODB__oci8.html#f221ba27a77d151136d538b3c6ce04df">ADODB_oci8::Prepare</a>($sql,$cursor); <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">// emulate handling of parameters ? ?, replacing with :bind0 :bind1</span> <a name="l00053"></a><a class="code" href="classADODB__oci8po.html#9c74c95a0e143fe6ef0c333aa4d2cd43">00053</a> function _query($sql,$inputarr) <a name="l00054"></a>00054 { <a name="l00055"></a>00055 <span class="keywordflow">if</span> (is_array($inputarr)) { <a name="l00056"></a>00056 $i = 0; <a name="l00057"></a>00057 <span class="keywordflow">if</span> (is_array($sql)) { <a name="l00058"></a>00058 foreach($inputarr as $v) { <a name="l00059"></a>00059 $arr['bind'.$i++] = $v; <a name="l00060"></a>00060 } <a name="l00061"></a>00061 } <span class="keywordflow">else</span> { <a name="l00062"></a>00062 $sqlarr = explode(<span class="charliteral">'?'</span>,$sql); <a name="l00063"></a>00063 $sql = $sqlarr[0]; <a name="l00064"></a>00064 foreach($inputarr as $k => $v) { <a name="l00065"></a>00065 $sql .= <span class="stringliteral">":$k"</span> . $sqlarr[++$i]; <a name="l00066"></a>00066 } <a name="l00067"></a>00067 } <a name="l00068"></a>00068 } <a name="l00069"></a>00069 <span class="keywordflow">return</span> <a class="code" href="classADODB__oci8.html#3488e64417285a6f853107631f8cb9e8">ADODB_oci8::_query</a>($sql,$inputarr); <a name="l00070"></a>00070 } <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="comment">/*--------------------------------------------------------------------------------------</span> <a name="l00074"></a>00074 <span class="comment"> Class Name: Recordset</span> <a name="l00075"></a>00075 <span class="comment">--------------------------------------------------------------------------------------*/</span> <a name="l00076"></a>00076 <a name="l00077"></a><a class="code" href="classADORecordset__oci8po.html">00077</a> <span class="keyword">class </span><a class="code" href="classADORecordset__oci8po.html">ADORecordset_oci8po</a> <span class="keyword">extends</span> <a class="code" href="classADORecordset__oci8.html">ADORecordset_oci8</a> { <a name="l00078"></a>00078 <a name="l00079"></a><a class="code" href="classADORecordset__oci8po.html#3e8ae5baea4cd42f3bf4700542a07df1">00079</a> var <a class="code" href="classADORecordset__oci8po.html#3e8ae5baea4cd42f3bf4700542a07df1">$databaseType</a> = 'oci8po'; <a name="l00080"></a>00080 <a name="l00081"></a><a class="code" href="classADORecordset__oci8po.html#fa88b1da937f069ae36bb95bbf54053c">00081</a> function <a class="code" href="classADORecordset__oci8po.html#fa88b1da937f069ae36bb95bbf54053c">ADORecordset_oci8po</a>($queryID,$mode=<span class="keyword">false</span>) <a name="l00082"></a>00082 { <a name="l00083"></a>00083 $this-><a class="code" href="classADORecordset__oci8.html#e54fae753b14f95d2f2b86c7e0b0d3f7">ADORecordset_oci8</a>($queryID,$mode); <a name="l00084"></a>00084 } <a name="l00085"></a>00085 <a name="l00086"></a><a class="code" href="classADORecordset__oci8po.html#10a19e33adea260ecb8613e52e691eb2">00086</a> function <a class="code" href="classADORecordset__oci8po.html#10a19e33adea260ecb8613e52e691eb2">Fields</a>($colname) <a name="l00087"></a>00087 { <a name="l00088"></a>00088 <span class="keywordflow">if</span> ($this->fetchMode & OCI_ASSOC) <span class="keywordflow">return</span> $this->fields[$colname]; <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="keywordflow">if</span> (!$this->bind) { <a name="l00091"></a>00091 $this->bind = array(); <a name="l00092"></a>00092 <span class="keywordflow">for</span> ($i=0; $i < $this->_numOfFields; $i++) { <a name="l00093"></a>00093 $o = $this-><a class="code" href="classADORecordset__oci8.html#e6b95d947e182034fced6ed928af010b">FetchField</a>($i); <a name="l00094"></a>00094 $this->bind[strtoupper($o->name)] = $i; <a name="l00095"></a>00095 } <a name="l00096"></a>00096 } <a name="l00097"></a>00097 <span class="keywordflow">return</span> $this->fields[$this->bind[strtoupper($colname)]]; <a name="l00098"></a>00098 } <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="comment">// lowercase field names...</span> <a name="l00101"></a><a class="code" href="classADORecordset__oci8po.html#3fc67cd7316b456f4b33c443e67e8cfb">00101</a> function &_FetchField($fieldOffset = -1) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 $fld = <span class="keyword">new</span> <a class="code" href="classADOFieldObject.html">ADOFieldObject</a>; <a name="l00104"></a>00104 $fieldOffset += 1; <a name="l00105"></a>00105 $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset)); <a name="l00106"></a>00106 $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); <a name="l00107"></a>00107 $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); <a name="l00108"></a>00108 <span class="keywordflow">if</span> ($fld->type == 'NUMBER') { <a name="l00109"></a>00109 <span class="comment">//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);</span> <a name="l00110"></a>00110 $sc = OCIColumnScale($this->_queryID, $fieldOffset); <a name="l00111"></a>00111 <span class="keywordflow">if</span> ($sc == 0) $fld->type = 'INT'; <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <span class="keywordflow">return</span> $fld; <a name="l00114"></a>00114 } <a name="l00115"></a>00115 <span class="comment">/*</span> <a name="l00116"></a>00116 <span class="comment"> function MoveNext()</span> <a name="l00117"></a>00117 <span class="comment"> {</span> <a name="l00118"></a>00118 <span class="comment"> if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {</span> <a name="l00119"></a>00119 <span class="comment"> $this->_currentRow += 1;</span> <a name="l00120"></a>00120 <span class="comment"> return true;</span> <a name="l00121"></a>00121 <span class="comment"> }</span> <a name="l00122"></a>00122 <span class="comment"> if (!$this->EOF) {</span> <a name="l00123"></a>00123 <span class="comment"> $this->_currentRow += 1;</span> <a name="l00124"></a>00124 <span class="comment"> $this->EOF = true;</span> <a name="l00125"></a>00125 <span class="comment"> }</span> <a name="l00126"></a>00126 <span class="comment"> return false;</span> <a name="l00127"></a>00127 <span class="comment"> }*/</span> <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">// 10% speedup to move MoveNext to child class</span> <a name="l00130"></a><a class="code" href="classADORecordset__oci8po.html#42c63fd43bb46c659077f6750ff8e80b">00130</a> function MoveNext() <a name="l00131"></a>00131 { <a name="l00132"></a>00132 <span class="keywordflow">if</span>(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { <a name="l00133"></a>00133 global $ADODB_ANSI_PADDING_OFF; <a name="l00134"></a>00134 $this->_currentRow++; <a name="l00135"></a>00135 <a name="l00136"></a>00136 <span class="keywordflow">if</span> ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); <a name="l00137"></a>00137 <span class="keywordflow">if</span> (!empty($ADODB_ANSI_PADDING_OFF)) { <a name="l00138"></a>00138 foreach($this->fields as $k => $v) { <a name="l00139"></a>00139 <span class="keywordflow">if</span> (is_string($v)) $this->fields[$k] = rtrim($v); <a name="l00140"></a>00140 } <a name="l00141"></a>00141 } <a name="l00142"></a>00142 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 <span class="keywordflow">if</span> (!$this->EOF) { <a name="l00145"></a>00145 $this->EOF = <span class="keyword">true</span>; <a name="l00146"></a>00146 $this->_currentRow++; <a name="l00147"></a>00147 } <a name="l00148"></a>00148 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="comment">/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */</span> <a name="l00152"></a><a class="code" href="classADORecordset__oci8po.html#687c3af62310b2de44837cceb0a0a8f3">00152</a> function &GetArrayLimit($nrows,$offset=-1) <a name="l00153"></a>00153 { <a name="l00154"></a>00154 <span class="keywordflow">if</span> ($offset <= 0) { <a name="l00155"></a>00155 $arr = $this->GetArray($nrows); <a name="l00156"></a>00156 <span class="keywordflow">return</span> $arr; <a name="l00157"></a>00157 } <a name="l00158"></a>00158 <span class="keywordflow">for</span> ($i=1; $i < $offset; $i++) <a name="l00159"></a>00159 <span class="keywordflow">if</span> (!@OCIFetch($this->_queryID)) { <a name="l00160"></a>00160 $arr = array(); <a name="l00161"></a>00161 <span class="keywordflow">return</span> $arr; <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <span class="keywordflow">if</span> (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { <a name="l00164"></a>00164 $arr = array(); <a name="l00165"></a>00165 <span class="keywordflow">return</span> $arr; <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <span class="keywordflow">if</span> ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); <a name="l00168"></a>00168 $results = array(); <a name="l00169"></a>00169 $cnt = 0; <a name="l00170"></a>00170 <span class="keywordflow">while</span> (!$this->EOF && $nrows != $cnt) { <a name="l00171"></a>00171 $results[$cnt++] = $this->fields; <a name="l00172"></a>00172 $this->MoveNext(); <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="keywordflow">return</span> $results; <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="comment">// Create associative array</span> <a name="l00179"></a><a class="code" href="classADORecordset__oci8po.html#d5c6b189889efb4bc88dba7e1461b95d">00179</a> function _updatefields() <a name="l00180"></a>00180 { <a name="l00181"></a>00181 <span class="keywordflow">if</span> (ADODB_ASSOC_CASE == 2) <span class="keywordflow">return</span>; <span class="comment">// native</span> <a name="l00182"></a>00182 <a name="l00183"></a>00183 $arr = array(); <a name="l00184"></a>00184 $lowercase = (ADODB_ASSOC_CASE == 0); <a name="l00185"></a>00185 <a name="l00186"></a>00186 foreach($this->fields as $k => $v) { <a name="l00187"></a>00187 <span class="keywordflow">if</span> (is_integer($k)) $arr[$k] = $v; <a name="l00188"></a>00188 <span class="keywordflow">else</span> { <a name="l00189"></a>00189 <span class="keywordflow">if</span> ($lowercase) <a name="l00190"></a>00190 $arr[strtolower($k)] = $v; <a name="l00191"></a>00191 <span class="keywordflow">else</span> <a name="l00192"></a>00192 $arr[strtoupper($k)] = $v; <a name="l00193"></a>00193 } <a name="l00194"></a>00194 } <a name="l00195"></a>00195 $this->fields = $arr; <a name="l00196"></a>00196 } <a name="l00197"></a>00197 <a name="l00198"></a><a class="code" href="classADORecordset__oci8po.html#f0deede7806faaeec54bac62d4402556">00198</a> function _fetch() <a name="l00199"></a>00199 { <a name="l00200"></a>00200 $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); <a name="l00201"></a>00201 <span class="keywordflow">if</span> ($ret) { <a name="l00202"></a>00202 global $ADODB_ANSI_PADDING_OFF; <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keywordflow">if</span> ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); <a name="l00205"></a>00205 <span class="keywordflow">if</span> (!empty($ADODB_ANSI_PADDING_OFF)) { <a name="l00206"></a>00206 foreach($this->fields as $k => $v) { <a name="l00207"></a>00207 <span class="keywordflow">if</span> (is_string($v)) $this->fields[$k] = rtrim($v); <a name="l00208"></a>00208 } <a name="l00209"></a>00209 } <a name="l00210"></a>00210 } <a name="l00211"></a>00211 <span class="keywordflow">return</span> $ret; <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <a name="l00214"></a>00214 } <a name="l00215"></a>00215 <a name="l00216"></a>00216 <a name="l00217"></a>00217 ?> </pre></div><?php include_once '../doc-typo3-funcs.php'; get_footer(); ?>