PatternTableSqlQuery.inc
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* $Id$
*
* Renders query results in a table.
*
* The first column in the table can be rendered as a link
* to the document/folder using the $iLinkType variable to specify the link type,
* the $sLinkPageURL to specify the page URL to link to and $sLinkImageURL to specify
* the image to display in the case of either a $iLinkType of 2 (image only) or 3 (image + text)
*
* If you wish to include images, there are two ways to do this
* o set the image url - this means that all rows will use the same image
* o set $bUseImageURLFromQuery to true - this will look for a column entitled image_url in
* the sql result set, allowing you to specify different images for each entry
*
* Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @version $Revision$
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @package lib.visualpatterns
* @todo $iLinkImageURL is hard coded - change
* @todo $sLinkPageURL is hard coded - change
*/
require_once('PatternTableGeneric.inc');
class SqlResultSetAdapter {
// Has there been an error setting up the result set?
var $broken = false;
function SqlResultSetAdapter ($oResultSet) {
global $default;
$this->oResultSet = $oResultSet;
if (PEAR::isError($oResultSet)) {
$this->broken = true;
}
}
function isEmpty () {
global $default;
if ($this->broken) {
return $this->oResultSet;
}
return ($this->oResultSet->numRows() == 0);
}
function next () {
global $default;
if ($this->broken) {
return $this->oResultSet;
}
$aNextResult = $this->oResultSet->fetchRow(DB_FETCHMODE_ASSOC);
if ($aNextResult === null) {
return null;
}
return new SqlResultAdapter ($aNextResult);
}
}
class SqlResultAdapter {
function SqlResultAdapter ($oResult) {
$this->oResult = $oResult;
}
function get ($sField) {
global $default;
return $this->oResult[$sField];
}
}
class PatternTableSqlQuery extends PatternTableGeneric {
function PatternTableSqlQuery($sTmpQuery, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aNewQueryStringVariableNames = null) {
$oResult = DBUtil::runQuery($sTmpQuery);
$oResultSet =& new SqlResultSetAdapter ($oResult);
$this->PatternTableGeneric($oResultSet, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaderNames, $sTmpWidth, $aTmpLinkURLs, $aTmpDBQueryStringColumns, $aNewQueryStringVariableNames);
}
}
?>