Project

General

Profile

Feature #24043 » exec_SELECTgetRowsByTriple.diff

Administrator Admin, 2010-11-13 19:05

View differences:

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()
*/
function exec_SELECT_getRowsByTriple($select, $tripleTable, $subjectTable, $predicateTable, $objectTable, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '') {
$tripleWhere = $subjectTable ? 'triple.subject_table=\''.$subjectTable.'\' AND subject.uid=triple.subject_uid' : '';
$tripleWhere .= ($subjectTable && ($predicateTable || $objectTable)) ? ' AND ' : '';
$tables = $tripleTable ? $tripleTable . ' AS triple,' : '';
$tables .= ',' . $subjectTable . ' AS subject';
if ($predicateTable) {
$tripleWhere .= 'triple.predicate_table=\''.$predicateTable.'\' AND predicate.uid=triple.predicate_uid';
$tripleWhere .= $objectTable ? ' AND ' : '';
$tables .= ',' . $predicateTable . ' AS predicate';
}
if ($objectTable) {
$tripleWhere .= 'triple.object_table=\''.$objectTable.'\' AND object.uid=triple.object_uid';
$tables .= ',' . $objectTable . ' AS object';
}
$tripleWhere = $whereClause ? '(' . $tripleWhere . ') AND '.$whereClause : $tripleWhere;
return $this->exec_SELECTquery(
$select,
$tables,
// whereClauseMightContainGroupOrderByButShouldNotContainThose
$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']);
}
?>
?>
(1-1/5)