DBA_Relational
[ class tree: DBA_Relational ] [ index: DBA_Relational ] [ all elements ]

Source for file TempTable.php

Documentation is available at TempTable.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | Copyright (c) 1997-2002 The PHP Group                                |
  4. // +----------------------------------------------------------------------+
  5. // | This source file is subject to version 2.0 of the PHP license,       |
  6. // | that is bundled with this package in the file LICENSE, and is        |
  7. // | available at through the world-wide-web at                           |
  8. // | http://www.php.net/license/2_02.txt.                                 |
  9. // | If you did not receive a copy of the PHP license and are unable to   |
  10. // | obtain it through the world-wide-web, please send a note to          |
  11. // | license@php.net so we can mail you a copy immediately.               |
  12. // +----------------------------------------------------------------------+
  13. // | Authors: Jacob Lee <jacobswell4u@yahoo.com>                          |
  14. // +----------------------------------------------------------------------+
  15. //
  16. // $Id: TempTable.php,v 1.3 2005/04/06 05:10:57 busterb Exp $
  17. //
  18.  
  19. /**
  20.  * Class for DBA Temporary Table Object
  21.  *
  22.  * Class name : DBA_TempTable
  23.  */
  24. class DBA_TempTable
  25. {
  26.     // {{{ instance variables
  27.     /**
  28.      * Contents of the temporary table
  29.      */
  30.     var $_rows;
  31.     // }}}
  32.  
  33.     // {{{ function DBA_TempTable($rows=null, $alias=null)
  34.     function DBA_TempTable($rows=null$alias=null)
  35.     {
  36.         if (!is_null($rows&& is_array($rows))
  37.             $this->setRows($rows$alias);
  38.     }
  39.     // }}}
  40.  
  41.     // {{{ function isTempTable($tTable)
  42.     function isTempTable($tTable)
  43.     {
  44.         return (is_object($tTable&&
  45.             (strtolower(get_class($tTable)) == 'dba_temptable' ||
  46.             is_subclass_of($tTable'dba_temptable')));
  47.     }
  48.     // }}}
  49.  
  50.     // {{{ function setRows($rows, $alias=null)
  51.     function setRows(&$rows$alias=null)
  52.     {
  53.         if (is_array($rows)) {
  54.             $v_rows = array();
  55.             
  56.             foreach ($rows as $row{
  57.                 foreach($row as $field=>$data{
  58.                     if ($field == '_rowid' || $field == '_timestamp')
  59.                         continue;
  60.                     if (is_string($alias&& strlen($alias))
  61.                         $v_row[$alias.'.'.$field$data;
  62.                     else $v_row[$field$data;
  63.                 }
  64.                 $v_rows[$v_row;
  65.             }
  66.             $this->_rows &$v_rows;
  67.         }
  68.     }
  69.     // }}}
  70.  
  71.     // {{{ function blankRow()
  72.     function blankRow()
  73.     {
  74.         $curRow current($this->_rows);
  75.         if ($curRow === false{
  76.             reset($this->_rows);
  77.             $curRow current($this->_rows);
  78.         }
  79.  
  80.         foreach ($curRow as $field=>$data{
  81.             if ($field{0== '_'// ignore system rows
  82.                 continue;
  83.             $blank[$field= null;
  84.         }
  85.         return $blank;
  86.     }
  87.     // }}}
  88.  
  89.     // {{{ function firstRow()
  90.     function firstRow()
  91.     {
  92.         $result reset($this->_rows);
  93.         if ($result === falsereturn $result;
  94.         return key($this->_rows);
  95.     }
  96.     // }}}
  97.  
  98.     // {{{ function nextRow()
  99.     function nextRow()
  100.     {
  101.         $result next($this->_rows);
  102.         if ($result === falsereturn $result;
  103.         return key($this->_rows);
  104.     }
  105.     // }}}
  106.  
  107.     // {{{ function getRow($key)
  108.     function getRow($key)
  109.     {
  110.         foreach ($this->_rows[$keyas $field=>$data{
  111.             if ($field{0== '_'// ignore system rows
  112.                 continue;
  113.             $row[$field$data;
  114.         }
  115.         return $row;
  116.     }
  117.     // }}}
  118.  
  119.     // {{{ function &getRows()
  120.     function &getRows()
  121.     {
  122.         return $this->_rows;
  123.     }
  124. }
  125.  
  126. ?>

Documentation generated on Mon, 11 Mar 2019 14:59:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.