Since the commit 11435 only :
SQL views are known to be used like tables.
Available in MySQL 5, they enable to :
- mask the schema complexity ( -> simplification of queries)
- give access to a limited number of fields ( -> security)
- manipulate calculated fields (sum(), max(), avg(), ..)
So you can avoid writing complex loops by using views :
Example :
mysql> create view v AS
SELECT a.titre,a.id_article,b.id_rubrique,b.titre AS titre_rub
FROM spip_articles AS a
LEFT JOIN spip_rubriques AS b ON(a.id_rubrique=b.id_rubrique)
WHERE b.titre REGEXP '^A'
ORDER BY a.titre DESC;
template :
<BOUCLE_n(V)>
<div>#TITRE : #TITRE_RUB</div>
</BOUCLE_n>
Fantastic, no ?
.Gilles
(PS.: note that views do not improve the performance of your queries,
so use them sparingly)