[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 /** 3 * ADOdb Lite Extend Module for Mysqlt 4 * 5 */ 6 7 eval('class postgres7_extend_EXTENDER extends '. $last_module . '_ADOConnection { }'); 8 9 class postgres7_extend_ADOConnection extends postgres7_extend_EXTENDER 10 { 11 function &GetAssoc($sql, $inputarr=false, $force_array = false, $first2cols = false) 12 { 13 $data = false; 14 $result =& $this->Execute($sql, $inputarr); 15 if ($result) { 16 $data =& $result->GetAssoc($force_array, $first2cols); 17 $result->Close(); 18 } 19 return $data; 20 } 21 22 /** 23 * Generates a sequence id and stores it in $this->genID; 24 * GenID is only available if $this->hasGenID = true; 25 * 26 * @param seqname name of sequence to use 27 * @param startID if sequence does not exist, start at this ID 28 * @return 0 if not supported, otherwise a sequence id 29 */ 30 31 var $_genIDSQL = "SELECT NEXTVAL('%s')"; 32 var $_genSeqSQL = "CREATE SEQUENCE %s START %s"; 33 var $_dropSeqSQL = "DROP SEQUENCE %s"; 34 var $genID = 0; 35 36 function GenID($seqname='adodbseq', $startID=1) 37 { 38 $getnext = sprintf($this->_genIDSQL, $seqname); 39 $holdtransOK = $this->transaction_status; 40 $save_handler = $this->raiseErrorFn; 41 $this->raiseErrorFn = ''; 42 @($result = $this->Execute($getnext)); 43 $this->raiseErrorFn = $save_handler; 44 45 if (!$result) { 46 $this->transaction_status = $holdtransOK; 47 $createseq = $this->Execute(sprintf($this->_genSeqSQL, $seqname, $startID)); 48 $result = $this->Execute($getnext); 49 } 50 if ($result && !$result->EOF) 51 $this->genID = reset($result->fields); 52 else $this->genID = 0; 53 54 if ($result) 55 $result->Close(); 56 57 return $this->genID; 58 } 59 60 function CreateSequence($seqname='adodbseq', $startID=1) 61 { 62 return $this->Execute(sprintf($this->_genSeqSQL, $seqname, $startID)); 63 } 64 65 function DropSequence($seqname='adodbseq') 66 { 67 return $this->Execute(sprintf($this->_dropSeqSQL, $seqname)); 68 } 69 70 } 71 72 eval('class postgres7_extend_resultset_EXTENDER extends '. $last_module . '_ResultSet { }'); 73 74 class postgres7_extend_ResultSet extends postgres7_extend_resultset_EXTENDER 75 { 76 function &GetAssoc($force_array = false, $first2cols = false) 77 { 78 $results = false; 79 80 if ($this->_numOfFields > 1) { 81 $numIndex = isset($this->fields[0]); 82 $results = array(); 83 if (!$first2cols && ($this->_numOfFields > 2 || $force_array)) { 84 if ($numIndex) { 85 while (!$this->EOF) { 86 $results[trim($this->fields[0])] = array_slice($this->fields, 1); 87 $this->MoveNext(); 88 } 89 } else { 90 while (!$this->EOF) { 91 $results[trim(reset($this->fields))] = array_slice($this->fields, 1); 92 $this->MoveNext(); 93 } 94 } 95 } else { 96 if ($numIndex) { 97 while (!$this->EOF) { 98 $results[trim(($this->fields[0]))] = $this->fields[1]; 99 $this->MoveNext(); 100 } 101 } else { 102 while (!$this->EOF) { 103 $v1 = trim(reset($this->fields)); 104 $v2 = ''.next($this->fields); 105 $results[$v1] = $v2; 106 $this->MoveNext(); 107 } 108 } 109 } 110 } 111 return $results; 112 } 113 114 function PO_RecordCount($table="", $condition="") 115 { 116 $lnumrows = $this->_numOfRows; 117 if($lnumrows == -1 && $this->connectionId) 118 { 119 if($table) 120 { 121 if ($condition) 122 $condition = " WHERE " . $condition; 123 $resultrows = &$this->connectionId->Execute("SELECT COUNT(*) FROM $table $condition"); 124 if ($resultrows) 125 $lnumrows = reset($resultrows->fields); 126 } 127 } 128 return $lnumrows; 129 } 130 131 function CurrentRow() 132 { 133 return $this->_currentRow; 134 } 135 136 function AbsolutePosition() 137 { 138 return $this->_currentRow; 139 } 140 141 function NextRecordSet() 142 { 143 return false; 144 } 145 146 } 147 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |