00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 require_once 'creole/ResultSet.php';
00023 require_once 'creole/common/ResultSetCommon.php';
00024
00032 abstract class ODBCResultSetCommon extends ResultSetCommon
00033 {
00038 protected $offset = 0;
00039
00044 protected $limit = 0;
00045
00049 public function __construct(Connection $conn, $result, $fetchmode = null)
00050 {
00051 parent::__construct($conn, $result, $fetchmode);
00052 }
00053
00057 public function close()
00058 {
00059 $this->result = null;
00060 $this->conn = null;
00061 $this->fetchmode = null;
00062 $this->cursorPos = 0;
00063 $this->fields = null;
00064 $this->lowerAssocCase = false;
00065 $this->limit = 0;
00066 $this->offset = 0;
00067 }
00068
00076 public function _setOffset($offset)
00077 {
00078 $this->offset = $offset;
00079 }
00080
00088 public function _setLimit($limit)
00089 {
00090 $this->limit = $limit;
00091 }
00092
00098 function getFieldNum($colname)
00099 {
00100 $fieldnum = 0;
00101
00102 if ($this->fetchmode == ResultSet::FETCHMODE_ASSOC)
00103 {
00104 $keys = array_keys($this->fields);
00105 $fieldnum = array_search($colname, $keys);
00106 }
00107
00108 return $fieldnum;
00109 }
00110
00125 protected function readLobData($column, $binmode, $curdata = null)
00126 {
00127
00128 $fldNum = (is_int($column) ? $column : getFieldNum($column));
00129
00130 $data = $curdata;
00131 $newdata = null;
00132
00133
00134 odbc_binmode($this->result->getHandle(), $binmode);
00135 odbc_longreadlen($this->result->getHandle(), 4096);
00136
00137 while (1)
00138 {
00139 $newdata = odbc_result($this->result->getHandle(), $fldNum);
00140
00141 if ($newdata === false)
00142 break;
00143 else
00144 $data .= $newdata;
00145 }
00146
00147
00148 odbc_binmode($this->result->getHandle(), ODBC_BINMODE_PASSTHRU);
00149 odbc_longreadlen($this->result->getHandle(), ini_get('odbc.defaultlrl'));
00150
00151
00152
00153 $data = rtrim($data, "\x0");
00154
00155 return $data;
00156 }
00157
00165 protected function checkFetchMode(&$row)
00166 {
00167 if ($this->fetchmode == ResultSet::FETCHMODE_ASSOC)
00168 {
00169 $newrow = array();
00170
00171 for ($i = 0, $n = count($row); $i < $n; $i++)
00172 {
00173 $colname = @odbc_field_name($this->result->getHandle(), $i+1);
00174
00175 if ($this->lowerAssocCase) {
00176 $colname = strtolower($colname);
00177 }
00178
00179 $newrow[$colname] = $row[$i];
00180 }
00181
00182 $row =& $newrow;
00183 }
00184
00185 return $row;
00186 }
00187
00188 }