Public Member Functions | |
executeQuery () | |
executeUpdate ($params=null) | |
setNull ($paramIndex) | |
setBlob ($paramIndex, $blob) | |
setClob ($paramIndex, $clob) | |
Protected Member Functions | |
replaceParams () | |
This does nothing since ODBC natively supports prepared statements. | |
_execute ($sql, $params, $fetchmode, $isupdate) | |
Internal function to call native ODBC prepare/execute functions. | |
escape ($str) |
Definition at line 33 of file ODBCPreparedStatement.php.
ODBCPreparedStatement::_execute | ( | $ | sql, | |
$ | params, | |||
$ | fetchmode, | |||
$ | isupdate | |||
) | [protected] |
Internal function to call native ODBC prepare/execute functions.
Definition at line 50 of file ODBCPreparedStatement.php.
References PreparedStatementCommon::$sql.
Referenced by executeQuery(), and executeUpdate().
00051 { 00052 if ($this->resultSet) 00053 { 00054 $this->resultSet->close(); 00055 $this->resultSet = null; 00056 } 00057 00058 $this->updateCount = null; 00059 00060 if ($this->conn->getAdapter()->emulatePrepareStmt()) 00061 { 00062 $stmt = @odbc_exec($this->conn->getResource(), $sql); 00063 $ret = ($stmt !== false); 00064 } 00065 else 00066 { 00067 // Trim surrounding quotes added from default set methods. 00068 // Exception: for LOB-based parameters, odbc_execute() will 00069 // accept a filename surrounded by single-quotes. 00070 foreach ($this->boundInVars as $idx => $var) 00071 { 00072 if ($var instanceof Lob) 00073 { 00074 $file = ($isupdate ? $var->getInputFile() : $var->getOutputFile()); 00075 $this->boundInVars[$idx] = "'$file'"; 00076 } 00077 else if (is_string($var)) 00078 { 00079 $this->boundInVars[$idx] = trim($var, "\"\'"); 00080 } 00081 } 00082 00083 $stmt = @odbc_prepare($this->conn->getResource(), $sql); 00084 00085 if ($stmt === FALSE) 00086 throw new SQLException('Could not prepare query', $this->conn->nativeError(), $sql); 00087 00088 $ret = @odbc_execute($stmt, $this->boundInVars); 00089 } 00090 00091 if ($ret === FALSE) 00092 { 00093 @odbc_free_result($stmt); 00094 throw new SQLException('Could not execute query', $this->conn->nativeError(), $sql); 00095 } 00096 00097 return $this->conn->createResultSet(new ODBCResultResource($stmt), $fetchmode); 00098 }
ODBCPreparedStatement::escape | ( | $ | str | ) | [protected] |
Reimplemented from PreparedStatementCommon.
Definition at line 170 of file ODBCPreparedStatement.php.
Referenced by setBlob(), and setClob().
00171 { 00172 if ($this->conn->getAdapter()->emulatePrepareStmt()) 00173 return $this->conn->getAdapter()->escape($str); 00174 00175 // Nothing to do here. odbc_execute() takes care of escaping strings. 00176 return $str; 00177 }
ODBCPreparedStatement::executeQuery | ( | ) |
Implements PreparedStatement.
Definition at line 103 of file ODBCPreparedStatement.php.
References PreparedStatementCommon::$sql, _execute(), and replaceParams().
00104 { 00105 switch (func_num_args()) { 00106 case 2: 00107 list($params, $fetchmode) = func_get_args(); 00108 if (!is_array($params)) { 00109 unset($params); 00110 } 00111 break; 00112 case 1: 00113 $params = null; 00114 list($fetchmode) = func_get_args(); 00115 break; 00116 case 0: 00117 $params = null; 00118 $fetchmode = null; 00119 break; 00120 } 00121 00122 // Set any params passed directly 00123 if (isset($params)) { 00124 for($i=0,$cnt=count($params); $i < $cnt; $i++) { 00125 $this->set($i+1, $params[$i]); 00126 } 00127 } 00128 00129 $sql = $this->replaceParams(); 00130 00131 if ($this->conn->getAdapter()->hasLimitOffset()) 00132 { 00133 if ($this->limit > 0 || $this->offset > 0) 00134 $this->conn->applyLimit($sql, $this->offset, $this->limit); 00135 } 00136 00137 $this->resultSet = $this->_execute($sql, $params, $fetchmode, false); 00138 00139 if (!$this->conn->getAdapter()->hasLimitOffset()) 00140 { 00141 $this->resultSet->_setOffset($this->offset); 00142 $this->resultSet->_setLimit($this->limit); 00143 } 00144 00145 return $this->resultSet; 00146 }
ODBCPreparedStatement::executeUpdate | ( | $ | params = null |
) |
Reimplemented from PreparedStatementCommon.
Definition at line 151 of file ODBCPreparedStatement.php.
References PreparedStatementCommon::$sql, _execute(), and replaceParams().
00152 { 00153 // Set any params passed directly 00154 if ($params) { 00155 for($i=0,$cnt=count($params); $i < $cnt; $i++) { 00156 $this->set($i+1, $params[$i]); 00157 } 00158 } 00159 00160 $sql = $this->replaceParams(); 00161 $this->_execute($sql, $params, 0, true); 00162 $this->updateCount = $this->conn->getUpdateCount(); 00163 00164 return $this->updateCount; 00165 }
ODBCPreparedStatement::replaceParams | ( | ) | [protected] |
This does nothing since ODBC natively supports prepared statements.
Reimplemented from PreparedStatementCommon.
Definition at line 39 of file ODBCPreparedStatement.php.
Referenced by executeQuery(), and executeUpdate().
00040 { 00041 if ($this->conn->getAdapter()->emulatePrepareStmt()) 00042 return parent::replaceParams(); 00043 else 00044 return $this->sql; 00045 }
ODBCPreparedStatement::setBlob | ( | $ | paramIndex, | |
$ | blob | |||
) |
Reimplemented from PreparedStatementCommon.
Definition at line 191 of file ODBCPreparedStatement.php.
References escape(), and setNull().
00192 { 00193 if ($this->conn->getAdapter()->emulatePrepareStmt()) 00194 return parent::setBlob($paramIndex, $blob); 00195 00196 $this->sql_cache_valid = false; 00197 if ($blob === null) 00198 { 00199 $this->setNull($paramIndex); 00200 return; 00201 } 00202 00203 if ($blob instanceof Blob) 00204 { 00205 if ($blob->isFromFile() && !$blob->isModified()) 00206 { 00207 $this->boundInVars[$paramIndex] = $blob; 00208 return; 00209 } 00210 00211 $blob = $blob->__toString(); 00212 } 00213 00214 $this->boundInVars[$paramIndex] = "'" . $this->escape($blob) . "'"; 00215 }
ODBCPreparedStatement::setClob | ( | $ | paramIndex, | |
$ | clob | |||
) |
Reimplemented from PreparedStatementCommon.
Definition at line 220 of file ODBCPreparedStatement.php.
References escape(), and setNull().
00221 { 00222 if ($this->conn->getAdapter()->emulatePrepareStmt()) 00223 return parent::setClob($paramIndex, $clob); 00224 00225 $this->sql_cache_valid = false; 00226 if ($clob === null) 00227 { 00228 $this->setNull($paramIndex); 00229 return; 00230 } 00231 00232 if ($clob instanceof Clob) 00233 { 00234 if ($clob->isFromFile() && !$clob->isModified()) 00235 { 00236 $this->boundInVars[$paramIndex] = $clob; 00237 return; 00238 } 00239 00240 $clob = $clob->__toString(); 00241 } 00242 00243 $this->boundInVars[$paramIndex] = "'" . $this->escape($clob) . "'"; 00244 }
ODBCPreparedStatement::setNull | ( | $ | paramIndex | ) |
Reimplemented from PreparedStatementCommon.
Definition at line 182 of file ODBCPreparedStatement.php.
Referenced by setBlob(), and setClob().