[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/adodb_lite/adodbSQL_drivers/mysqli/ -> mysqli_extend_module.inc (source)

   1  <?php
   2  /**

   3   * ADOdb Lite Extend Module for Mysqlt

   4   * 

   5   */
   6  
   7  eval('class mysqli_extend_EXTENDER extends '. $last_module . '_ADOConnection { }');
   8  
   9  class mysqli_extend_ADOConnection extends mysqli_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 = "update %s set id=LAST_INSERT_ID(id+1);";
  32      var $_genSeqSQL = "create table %s (id int not null)";
  33      var $_genSeq2SQL = "insert into %s values (%s)";
  34      var $_dropSeqSQL = "drop table %s";
  35      var $genID = 0;
  36  
  37  	function GenID($seqname='adodbseq', $startID=1)
  38      {
  39          $getnext = sprintf($this->_genIDSQL, $seqname);
  40          $holdtransOK = $this->transaction_status;
  41          $result = @$this->Execute($getnext);
  42          if (!$result) {
  43              if ($holdtransOK)
  44                  $this->transaction_status = true;
  45  //            $u = strtoupper($seqname);

  46              $this->Execute(sprintf($this->_genSeqSQL, $seqname));
  47              $this->Execute(sprintf($this->_genSeq2SQL, $seqname, $startID-1));
  48              $result = $this->Execute($getnext);
  49          }
  50          $this->genID = mysqli_insert_id($this->connectionId);
  51  
  52          if ($result)
  53              $result->Close();
  54  
  55          return $this->genID;
  56      }
  57  
  58  	function CreateSequence($seqname='adodbseq',$startID=1)
  59      {
  60          $u = strtoupper($seqname);
  61  
  62          $ok = $this->Execute(sprintf($this->_genSeqSQL, $seqname));
  63          if (!$ok)
  64              return false;
  65          return $this->Execute(sprintf($this->_genSeq2SQL, $seqname, $startID-1));
  66      }
  67  
  68  	function DropSequence($seqname='adodbseq')
  69      {
  70          return $this->Execute(sprintf($this->_dropSeqSQL, $seqname));
  71      }
  72  
  73  }
  74  
  75  eval('class mysqli_extend_resultset_EXTENDER extends '. $last_module . '_ResultSet { }');
  76  
  77  class mysqli_extend_ResultSet extends mysqli_extend_resultset_EXTENDER
  78  {
  79      function &GetAssoc($force_array = false, $first2cols = false) 
  80      {
  81          $results = false;
  82          
  83          if ($this->_numOfFields > 1) {
  84              $numIndex = isset($this->fields[0]);
  85              $results = array();
  86              if (!$first2cols && ($this->_numOfFields > 2 || $force_array)) {
  87                  if ($numIndex) {
  88                      while (!$this->EOF) {
  89                          $results[trim($this->fields[0])] = array_slice($this->fields, 1);
  90                          $this->MoveNext();
  91                      }
  92                  } else {
  93                      while (!$this->EOF) {
  94                          $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
  95                          $this->MoveNext();
  96                      }
  97                  }
  98              } else {
  99                  if ($numIndex) {
 100                      while (!$this->EOF) {
 101                          $results[trim(($this->fields[0]))] = $this->fields[1];
 102                          $this->MoveNext();
 103                      }
 104                  } else {
 105                      while (!$this->EOF) {
 106                          $v1 = trim(reset($this->fields));
 107                          $v2 = ''.next($this->fields); 
 108                          $results[$v1] = $v2;
 109                          $this->MoveNext();
 110                      }
 111                  }
 112              }
 113          }
 114          return $results; 
 115      }
 116  
 117  	function PO_RecordCount($table="", $condition="")
 118      {
 119          $lnumrows = $this->_numOfRows;
 120          if($lnumrows == -1 && $this->connectionId)
 121          {
 122              if($table)
 123              {
 124                  if ($condition)
 125                      $condition = " WHERE " . $condition; 
 126                  $resultrows = &$this->connectionId->Execute("SELECT COUNT(*) FROM $table $condition");
 127                  if ($resultrows)
 128                      $lnumrows = reset($resultrows->fields);
 129              }
 130          }
 131          return $lnumrows;
 132      }
 133  
 134  	function CurrentRow()
 135      {
 136          return $this->_currentRow;
 137      }
 138  
 139  	function AbsolutePosition()
 140      {
 141          return $this->_currentRow;
 142      }
 143  
 144  	function NextRecordSet()
 145      {
 146          return false;
 147      }
 148  
 149  }
 150  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7