forked from digedag/cfc_league
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.tx_cfcleague_db.php
More file actions
149 lines (129 loc) · 4.83 KB
/
Copy pathclass.tx_cfcleague_db.php
File metadata and controls
149 lines (129 loc) · 4.83 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/***************************************************************
* Copyright notice
*
* (c) 2007 Rene Nitzsche (rene@system25.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project 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.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Klasse für Datenbankabfragen
*/
class tx_cfcleague_db{
/**
* Stellt eine Anfrage an die DB und liefert die ermittelten Zeilen zurück
* @param $what requested columns
* @param $where
* @param $from either the name of a table or an array with index 0 the from clause
* and index 1 the requested tablename
*/
function queryDB($what, $where, $from=TABLE_GAMES, $groupBy = '', $orderBy = '', $debug=0, $limit = ''){
if($debug)
$time = microtime(true);
$tableName = $from;
$fromClause = $from;
if(is_array($from)){
$tableName = $from[1];
$fromClause = $from[0];
}
// Zur Where-Clause noch die gültigen Felder hinzufügen
$where .= t3lib_BEfunc::deleteClause($tableName);
if($debug) {
$sql = $GLOBALS['TYPO3_DB']->SELECTquery($what, $fromClause, $where, $groupBy, $orderBy);
tx_rnbase_util_Debug::debug($sql, 'SQL (tx_cfcleague_db)');
tx_rnbase_util_Debug::debug(array($what, $from, $where), 'Params (tx_cfcleague_db)');
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$what,
$fromClause,
$where,
$groupBy,
$orderBy,
$limit
);
$rows = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)){
$rows[] = $row;
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
if($debug)
tx_rnbase_util_Debug::debug(count($rows), 'Rows retrieved (tx_cfcleague_db) Time: ' . (microtime(true) - $time) . 's');
return $rows;
}
/**
* Schickt einen Update an die Datenbank und schreibt die Aktion ins Log
* Die Methode verwendet intern eine Instanz der TCEmain. Diese wird static
* vorgehalten, so daß mehrmalige Aufrufe kein Problem sind
* @param $tce eine Instanz der TCEmain, Sinnvoll wenn man viele Updates auf einmal ausführt
*/
function updateDB($table, $uid, $dataArr){
$tce =& tx_cfcleague_db::getTCEmain();
$tce->updateDB($table, $uid, $dataArr);
}
/**
* Liefert eine initialisierte TCEmain Instanz
*/
function &getTCEmain($data = 0) {
static $tce;
if(!$tce || $data) {
// Die TCEmain laden
$tce = t3lib_div::makeInstance('t3lib_tcemain');
$tce->stripslashes_values = 0;
// Wenn wir ein data-Array bekommen verwenden wir das
$tce->start($data ? $data : Array(), Array());
// set default TCA values specific for the user
$TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
if (is_array($TCAdefaultOverride)) {
$tce->setDefaultsFromUserTS($TCAdefaultOverride);
}
// t3lib_div::debug('NEW TCEmain instance created', 'cfcleague_db');
}
return $tce;
}
/**
* Backend method to determine if a page is below a page
*/
public function getPagePath($uid, $clause='') {
$loopCheck = 100;
$output = array(); // We return an array of uids
$output[] = $uid;
while ($uid!=0 && $loopCheck>0) {
$loopCheck--;
//'uid,pid,title,t3ver_oid,t3ver_wsid,t3ver_swapmode',
$rows = tx_rnbase_util_DB::doSelect('*', 'pages', array(
'where' => 'uid='.intval($uid).(strlen(trim($clause)) ? ' AND '.$clause : ''),
));
if(!empty($rows)) {
$row = reset($rows);
t3lib_BEfunc::workspaceOL('pages', $row);
t3lib_BEfunc::fixVersioningPid('pages', $row);
$uid = $row['pid'];
$output[] = $uid;
// $output = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$titleLimit).$output;
// if ($fullTitleLimit) $fullOutput = '/'.t3lib_div::fixed_lgd_cs(strip_tags($row['title']),$fullTitleLimit).$fullOutput;
} else {
break;
}
}
return $output;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cfc_league/class.tx_cfcleague_db.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cfc_league/class.tx_cfcleague_db.php']);
}
?>