MSSQLPreparedStatement.php

Go to the documentation of this file.
00001 <?php 00002 /* 00003 * $Id: MSSQLPreparedStatement.php,v 1.1 2004/05/03 16:25:27 micha Exp $ 00004 * 00005 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00006 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00007 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00008 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00009 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00010 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00011 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00012 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00013 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00014 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00015 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00016 * 00017 * This software consists of voluntary contributions made by many individuals 00018 * and is licensed under the LGPL. For more information please see 00019 * <http://creole.phpdb.org>. 00020 */ 00021 00022 require_once 'creole/PreparedStatement.php'; 00023 require_once 'creole/common/PreparedStatementCommon.php'; 00024 00033 class MSSQLPreparedStatement extends PreparedStatementCommon 00034 { 00046 function setBlob($paramIndex, $blob) 00047 { 00048 if ($blob === null) { 00049 $this->setNull($paramIndex); 00050 } else { 00051 // they took magic __toString() out of PHP5.0.0; this sucks 00052 if (is_object($blob)) { 00053 $blob = $blob->__toString(); 00054 } 00055 $data = unpack("H*hex", $blob); 00056 $this->boundInVars[$paramIndex] = '0x'.$data['hex']; // no surrounding quotes! 00057 } 00058 } 00059 00065 function escape($subject) 00066 { 00067 // use this instead of magic_quotes_sybase + addslashes(), 00068 // just in case multiple RDBMS being used at the same time 00069 return str_replace("'", "''", $subject); 00070 } 00071 00076 function & executeQuery($p1 = null, $fetchmode = null) 00077 { 00078 $params = null; 00079 if ($fetchmode !== null) { 00080 $params = $p1; 00081 } elseif ($p1 !== null) { 00082 if (is_array($p1)) $params = $p1; 00083 else $fetchmode = $p1; 00084 } 00085 00086 if ($params) { 00087 for($i=0,$cnt=count($params); $i < $cnt; $i++) { 00088 $this->set($i+1, $params[$i]); 00089 } 00090 } 00091 00092 $this->updateCount = null; // reset 00093 $sql =& $this->replaceParams(); 00094 00095 if (Creole::isError($sql)) { 00096 return $sql; 00097 } 00098 00099 if ($this->offset > 0 && $this->limit <= 0) { 00100 return new SQLException(CREOLE_ERROR, 'Cannot specify an offset without limit.'); 00101 } 00102 00103 $this->resultSet =& $this->conn->executeQuery($sql, $fetchmode); 00104 if (Creole::isError($this->resultSet)) { return $this->resultSet; } 00105 $this->resultSet->_setOffset($this->offset); 00106 $this->resultSet->_setLimit($this->limit); 00107 return $this->resultSet; 00108 } 00109 00110 }

This file is part of the Creole[php4] library.


Copyright © 2004 Hans Lellelid  
Creole[php4] CVS