Automating joins

When they have not been explicitly declared to SPIP, joins are calculated where they are possible. To do this, SPIP compares the names of the fields of the various tables.

For example, if an AUTEURS loop looks for a criteria field that is not in its table, perhaps {prenom=Daniel} for example, SPIP will go and look in the other tables that it knows of and which have fields with the same names as the auteur table (like the id_auteur key field), to see if such tables have the "prenom" field being requested. If one of the tables does have that field, then a join will be made between these two tables.

For example, if a custom table AUTEURS_ELARGIS (extended_authors) exists (as it does for the "Inscription 2" plugin) with both of the fields "id_auteur" and "prenom", a join would be made to enable the previously mentioned loop criterion to operate correctly.

object, id_object

SPIP 2.0 introduced a new method of searching for joins. The primary keys of one table, in this case "id_auteur" for the spip_auteurs table, as well as being searched for in the field names of the other tables, are also searched for in tables that have the pair of fields "object" and "id_object", where "objet=auteur" in our example. In the current SPIP standard database schema, this is actually the case for the spip_documents_liens table.

Author Mark Baber Published : Updated : 28/06/10

Translations : English, français, Nederlands