[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: MSSQLPreparedStatement.php,v 1.13 2005/11/13 01:29:01 gamr Exp $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://creole.phpdb.org>. 20 */ 21 22 require_once 'creole/PreparedStatement.php'; 23 require_once 'creole/common/PreparedStatementCommon.php'; 24 25 /** 26 * MSSQL specific PreparedStatement functions. 27 * 28 * @author Hans Lellelid <hans@xmpl.org> 29 * @version $Revision: 1.13 $ 30 * @package creole.drivers.mssql 31 */ 32 class MSSQLPreparedStatement extends PreparedStatementCommon implements PreparedStatement { 33 34 /** 35 * MSSQL-specific implementation of setBlob(). 36 * 37 * If you are having trouble getting BLOB data into the database, see the phpdoc comment 38 * in the MSSQLConnection for some PHP ini values that may need to be set. (This also 39 * applies to CLOB support.) 40 * 41 * @param int $paramIndex 42 * @param mixed $value Blob object or string. 43 * @return void 44 */ 45 function setBlob($paramIndex, $blob) 46 { 47 $this->sql_cache_valid = false; 48 if ($blob === null) { 49 $this->setNull($paramIndex); 50 } else { 51 // they took magic __toString() out of PHP5.0.0; this sucks 52 if (is_object($blob)) { 53 $blob = $blob->__toString(); 54 } 55 $data = unpack("H*hex", $blob); 56 $this->boundInVars[$paramIndex] = '0x'.$data['hex']; // no surrounding quotes! 57 } 58 } 59 60 61 /** 62 * Add quotes using str_replace. 63 * This is not as thorough as MySQL. 64 */ 65 protected function escape($subject) 66 { 67 // use this instead of magic_quotes_sybase + addslashes(), 68 // just in case multiple RDBMS being used at the same time 69 return str_replace("'", "''", $subject); 70 } 71 72 /** 73 * MSSQL must emulate OFFSET/LIMIT support. 74 */ 75 public function executeQuery($p1 = null, $fetchmode = null) 76 { 77 $params = null; 78 if ($fetchmode !== null) { 79 $params = $p1; 80 } elseif ($p1 !== null) { 81 if (is_array($p1)) $params = $p1; 82 else $fetchmode = $p1; 83 } 84 85 if ($params) { 86 for($i=0,$cnt=count($params); $i < $cnt; $i++) { 87 $this->set($i+1, $params[$i]); 88 } 89 } 90 91 $this->updateCount = null; // reset 92 $sql = $this->replaceParams(); 93 94 $this->resultSet = $this->conn->executeQuery($sql, $fetchmode); 95 $this->resultSet->_setOffset($this->offset); 96 $this->resultSet->_setLimit($this->limit); 97 return $this->resultSet; 98 } 99 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |