[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: OCI8ResultSet.php,v 1.13 2006/01/17 19:44:40 hlellelid 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/ResultSet.php'; 23 require_once 'creole/common/ResultSetCommon.php'; 24 25 /** 26 * Oracle (OCI8) implementation of ResultSet class. 27 * 28 * @author David Giffin <david@giffin.org> 29 * @author Hans Lellelid <hans@xmpl.org> 30 * @version $Revision: 1.13 $ 31 * @package creole.drivers.oracle 32 */ 33 class OCI8ResultSet extends ResultSetCommon implements ResultSet 34 { 35 /** 36 * @see ResultSet::seek() 37 */ 38 function seek($rownum) 39 { 40 if ( $rownum < $this->cursorPos ) 41 { 42 // this will effectively disable previous(), first() and some calls to relative() or absolute() 43 throw new SQLException( 'Oracle ResultSet is FORWARD-ONLY' ); 44 } 45 46 // Oracle has no seek function imulate it here 47 while ( $this->cursorPos < $rownum ) 48 { 49 $this->next(); 50 } 51 52 $this->cursorPos = $rownum; 53 54 return true; 55 } 56 57 /** 58 * @see ResultSet::next() 59 */ 60 function next() 61 { 62 // no specific result position available 63 64 // Returns an array, which corresponds to the next result row or FALSE 65 // in case of error or there is no more rows in the result. 66 $this->fields = oci_fetch_array( $this->result 67 , $this->fetchmode 68 + OCI_RETURN_NULLS 69 + OCI_RETURN_LOBS 70 ); 71 72 if ( ! $this->fields ) 73 { 74 // grab error via array 75 $error = oci_error( $this->result ); 76 77 if ( ! $error ) 78 { 79 // end of recordset 80 $this->afterLast(); 81 82 return false; 83 } 84 85 else 86 { 87 throw new SQLException( 'Error fetching result' 88 , $error[ 'code' ] . ': ' . $error[ 'message' ] 89 ); 90 } 91 } 92 93 // Oracle returns all field names in uppercase and associative indices 94 // in the result array will be uppercased too. 95 if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) 96 { 97 $this->fields = array_change_key_case($this->fields, CASE_LOWER); 98 } 99 100 // Advance cursor position 101 $this->cursorPos++; 102 103 return true; 104 } 105 106 /** 107 * @see ResultSet::getRecordCount() 108 */ 109 function getRecordCount() 110 { 111 $rows = oci_num_rows( $this->result ); 112 113 if ( $rows === false ) 114 { 115 throw new SQLException( 'Error fetching num rows' 116 , $this->conn->nativeError( $this->result ) 117 ); 118 } 119 120 return ( int ) $rows; 121 } 122 123 /** 124 * @see ResultSet::close() 125 */ 126 function close() 127 { 128 $this->fields = array(); 129 @oci_free_statement( $this->result ); 130 } 131 }
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 |