[TYPO3-core] RFC #16376: Feature: New TYPO3_DB method for select queries that fetch data from up to 3 tables based on RDF like triples
Jigal van Hemert
jigal at xs4all.nl
Sun Nov 14 09:52:41 CET 2010
Hi,
On 13-11-2010 19:56, JoH asenau wrote:
>> v2 follows
> here we go
In the past I needed the concept of MMM-relationships and was told that
it was possible using multiple tables in a kind of IRRE construction. In
the end we made a MMM-table to store relations which unfortunately
lacked support in the TCE forms. So hooray for this option.
* @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
If these are optional, the function declaration should reflect this:
public function exec_SELECT_getRowsByTriple($select, $tripleTable,
$subjectTable, $predicateTable = FALSE, $objectTable = FALSE,
$whereClause = '', $groupBy = '', $orderBy = '', $limit = '') {
To be consistent with the naming of the existing methods the second
underscore in the function name should go: exec_SELECTgetRowsByTriple()
(see: exec_SELECTgetRows() )
Furthermore I would like to see support for prepared statements with
triple tables. Could you please add the necessary methods for this?
Compared with exec_SELECT_mm_query() the parameters are in a different
order: local_table, mm_table, foreign_table. The naming of 'subject',
'predicate' and 'object' seems derived from RDF triples, but this looks
like a different concept [1], RDF triples are more like a collection of
named variables which belong to a record: subject-predicate-object =
recordId-variableName-variableValue.
An MMM-relationship would for me mean: localTable, mmmTable,
foreignTable, secondForeignTable.
You could implement RDF triples with MMM-tables if you store predicates
and objects in separate tables, but this would only mean that your RDF
implementation uses MMM-tables. The names in a generic methods such as
exec_SELECT_mmm_query, exec_SELECTgetRowsFromMMM would have to be more
generic :-)
$tables = $tripleTable ? $tripleTable . ' AS triple,' : '';
$tables .= ',' . $subjectTable . ' AS subject';
If $tripleTable is set this will end up as:
tripleTable AS triple,,subjectTable AS subject
else it will end up as:
,subjectTable AS subject
Both seem incorrect to me. Besides, I prefer an explicit JOIN instead of
the almost invisible comma.
Because later on more tables are added, maybe $tables should be an array
which is later on imploded with ' JOIN ' (or ', ' if you insist on using
that).
Also, if $tripleTable is not optional, why test for it with the ternary
operator?
return $this->exec_SELECTquery($select, $tables, $tripleWhere, $groupBy,
$orderBy, $limit);
Hmm... exec_SELECTgetRows() returns an array with the actual records,
but this function returns a MySQL result point or DBAL object. Shouldn't
it be named exec_SELECT_mmm_query() ?
And last but not least: it needs support in TCA and TCE forms. As it is
a new concept (a relation with two tables) new form controls need to be
build. Yes, MMM-tables would be very useful for various situations, but
I'm afraid it needs more than a single method in t3lib_DB.
-1 for this version.
[1] http://goo.gl/H3Jgb
--
Kind regards / met vriendelijke groet,
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh
More information about the TYPO3-team-core
mailing list