Feature #24043 » exec_SELECTgetRowsByTriple_v2.diff
t3lib/class.t3lib_db.php (revision ) | ||
---|---|---|
);
|
||
}
|
||
|
||
|
||
/**
|
||
* Creates and executes a SELECT query, selecting fields ($select) from four tables joined
|
||
* Use $tripleTable together with $subjectTable, $predicateTable or $objectTable to select over two tables. Or use all four tables to select a full MMM-relation.
|
||
* The JOIN is done with triple.subject_uid <--> subject.uid / triple.predicate_uid <--> predicate.uid / triple.object_uid <--> object.uid
|
||
* The function is very useful for selecting MMM-relations like RDF triples
|
||
*
|
||
* @param string Field list for SELECT
|
||
* @param string Tablename, triple table, renamed to triple
|
||
* @param string Tablename, subject table, renamed to subject
|
||
* @param string Optional Tablename, predicate table, renamed to predicate
|
||
* @param string Optional Tablename, object table, renamed to object
|
||
* @param string Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT! You have to prepend 'AND ' to this parameter yourself!
|
||
* @param string Optional GROUP BY field(s), if none, supply blank string.
|
||
* @param string Optional ORDER BY field(s), if none, supply blank string.
|
||
* @param string Optional LIMIT value ([begin,]max), if none, supply blank string.
|
||
* @return pointer MySQL result pointer / DBAL object
|
||
* @see exec_SELECTquery()
|
||
*/
|
||
public function exec_SELECT_getRowsByTriple($select, $tripleTable, $subjectTable, $predicateTable, $objectTable, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '') {
|
||
|
||
if($subjectTable) {
|
||
$tripleWhere = 'triple.subject_table=' . $this->fullQuoteStr($subjectTable,$tripleTable) . ' AND subject.uid=triple.subject_uid';
|
||
}
|
||
if($subjectTable && ($predicateTable || $objectTable)) {
|
||
$tripleWhere .= ' AND ';
|
||
}
|
||
|
||
$tables = $tripleTable ? $tripleTable . ' AS triple,' : '';
|
||
$tables .= ',' . $subjectTable . ' AS subject';
|
||
|
||
if ($predicateTable) {
|
||
$tripleWhere .= 'triple.predicate_table=' . $this->fullQuoteStr($predicateTable,$tripleTable) .' AND predicate.uid=triple.predicate_uid';
|
||
if($objectTable) {
|
||
$tripleWhere .= ' AND ';
|
||
}
|
||
|
||
$tables .= ',' . $predicateTable . ' AS predicate';
|
||
}
|
||
|
||
if ($objectTable) {
|
||
$tripleWhere .= 'triple.object_table=' . $this->fullQuoteStr($objectTable,$tripleTable) . ' AND object.uid=triple.object_uid';
|
||
|
||
$tables .= ',' . $objectTable . ' AS object';
|
||
}
|
||
|
||
if($whereClause) {
|
||
$tripleWhere = '(' . $tripleWhere . ') AND ' . $whereClause;
|
||
}
|
||
|
||
return $this->exec_SELECTquery(
|
||
$select,
|
||
$tables,
|
||
$tripleWhere,
|
||
$groupBy,
|
||
$orderBy,
|
||
$limit
|
||
);
|
||
}
|
||
|
||
/**
|
||
* Executes a select based on input query parts array
|
||
*
|
||
* Usage: 9
|
||
... | ... | |
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_db.php']);
|
||
}
|
||
|
||
?>
|
||
?>
|