| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php'); 10 lmb_require('limb/dbal/src/drivers/oci/lmbOciRecord.class.php'); 11 12 /** 13 * class lmbOciRecordSet. 14 * 15 * @package dbal 16 * @version $Id: lmbOciRecordSet.class.php 5945 2007-06-06 08:31:43Z pachanga $ 17 */ 18 class lmbOciRecordSet extends lmbDbBaseRecordSet 19 { 20 protected $queryId; 21 protected $query; 22 protected $original_stmt; 23 protected $stmt; 24 protected $connection; 25 26 protected $need_pager = false; 27 28 protected $current; 29 protected $valid; 30 protected $key; 31 32 function __construct($connection, $stmt) 33 { 34 $this->connection = $connection; 35 $this->stmt = $stmt; 36 $this->original_stmt = clone $stmt; //used for getting total count 37 $this->query = $stmt->getSQL(); 38 } 39 40 function paginate($offset, $limit) 41 { 42 $this->offset = $offset; 43 $this->limit = $limit; 44 $this->need_pager = true; 45 return $this; 46 } 47 48 function freeQuery() 49 { 50 if(isset($this->queryId) && is_resource($this->queryId)) 51 { 52 oci_free_statement($this->queryId); 53 $this->queryId = null; 54 } 55 } 56 57 function rewind() 58 { 59 $stmt = $this->_prepareStatement(); 60 $this->queryId = $stmt->execute(); 61 $this->_prefetch(); 62 63 $this->key = 0; 64 $this->next(); 65 } 66 67 protected function _prepareStatement() 68 { 69 if($this->sort_params) 70 $this->stmt->addOrder($this->sort_params); 71 72 if($this->need_pager) 73 $this->stmt->paginate($this->offset, $this->limit); 74 75 return $this->stmt; 76 } 77 78 protected function _prefetch() 79 { 80 if(!$this->need_pager) 81 { 82 if($total_row_count = $this->stmt->count()) 83 oci_set_prefetch($this->queryId, $total_row_count); 84 } 85 else 86 oci_set_prefetch($this->queryId, $this->limit); 87 } 88 89 function next() 90 { 91 $this->current = new lmbOciRecord(); 92 $values = oci_fetch_array($this->queryId, OCI_ASSOC+OCI_RETURN_NULLS); 93 $this->current->import($values); 94 $this->valid = is_array($values); 95 $this->key++; 96 } 97 98 function valid() 99 { 100 return $this->valid; 101 } 102 103 function current() 104 { 105 return $this->current; 106 } 107 108 function key() 109 { 110 return $this->key; 111 } 112 113 function at($pos) 114 { 115 $stmt = clone $this->stmt; 116 if($this->sort_params) 117 $stmt->addOrder($this->sort_params); 118 $stmt->paginate($pos, 1); 119 120 $queryId = $stmt->execute(); 121 122 $arr = oci_fetch_array($queryId, OCI_ASSOC+OCI_RETURN_NULLS); 123 oci_free_statement($queryId); 124 if(is_array($arr)) 125 return new lmbOciRecord($arr); 126 } 127 128 function countPaginated() 129 { 130 if($this->need_pager) 131 $this->stmt->paginate($this->offset, $this->limit); 132 133 return $this->stmt->count(); 134 } 135 136 function count() 137 { 138 return $this->original_stmt->count(); 139 } 140 } 141 142 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Sep 6 04:46:52 2008 | Cross-referenced by PHPXref 0.7 |