Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (114 sloc) 3.09 kB
0ff1002 added DBA_Relationa::dropTable(), a new temporary table class
Brent Cook authored
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$
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))
25f3dac various superbowl fixups
Brent Cook authored
37 $this->setRows($rows, $alias);
0ff1002 added DBA_Relationa::dropTable(), a new temporary table class
Brent Cook authored
38 }
39 // }}}
40
41 // {{{ function isTempTable($tTable)
42 function isTempTable($tTable)
43 {
44 return (is_object($tTable) &&
a632681 Use case-insensitive class comparison for PHP 5
Brent Cook authored
45 (strtolower(get_class($tTable)) == 'dba_temptable' ||
0ff1002 added DBA_Relationa::dropTable(), a new temporary table class
Brent Cook authored
46 is_subclass_of($tTable, 'dba_temptable')));
47 }
48 // }}}
49
50 // {{{ function setRows($rows, $alias=null)
25f3dac various superbowl fixups
Brent Cook authored
51 function setRows(&$rows, $alias=null)
0ff1002 added DBA_Relationa::dropTable(), a new temporary table class
Brent Cook authored
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 === false) return $result;
94 return key($this->_rows);
95 }
96 // }}}
97
98 // {{{ function nextRow()
99 function nextRow()
100 {
101 $result = next($this->_rows);
102 if ($result === false) return $result;
103 return key($this->_rows);
104 }
105 // }}}
106
107 // {{{ function getRow($key)
108 function getRow($key)
109 {
110 foreach ($this->_rows[$key] as $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 ?>
Something went wrong with that request. Please try again.