The following SQL-Moslates are the implementation of some SQL-Tags specified by the JSTL.
(To use those, you need to import logic_export)
sql:query
var(default:rows), scope(optional), sql(optional)
... ? ... : ...
accessing properties
|
0 |
http://www.joomla.org | 1 |
http://www.opensourcematters.org | 2 |
http://www.php.net | 3 |
http://www.mysql.com | 4 |
http://developer.joomla.org/ |
|
{sql:query var="rows"}
SELECT title, url FROM #__weblinks
{/sql:query}
<table border="1">
<tr><th colspan="2">rows
({c:out value="${fn:length(rows)}"/})</th></tr>
{c:forEach items="${rows}" var="row"}
<tr><td rowspan="2" style="font-weight:{c:out value="${row.key % 2 == 0 ? 'bold' : 'thin'};"/}">{c:out value="${row.key}"/}</td>
<th colspan="2">
{c:out value="${row.value['title']}"/}
</th></tr>
<tr><td>{c:out value="${row.value.url}"/}</td></tr>
{/c:forEach}
</table>
|
sql:update
var(default:rows), scope(optional), sql(optional)
sql:param
value
|
affected rows: 1
count: 1
0=O:8:"stdClass":2:{s:5:"title";s:6:"Loomla";s:3:"url";s:21:"http://www.joomla.org";}
affected rows: 1
|
{c:set var="oldTitle" value="Joomla"/}
{c:set var="newTitle" value="Loomla"/}
{sql:update var="affectedRows"
sql="UPDATE #__weblinks SET title = '${newTitle}' WHERE title = '${oldTitle}'"/}
affected rows: {c:out value="${affectedRows}"/}<br/>
{sql:query var="rows"
sql="SELECT title, url FROM #__weblinks WHERE title = ?"}
{sql:param value="${newTitle}"/}
{/sql:query}
count: {c:out value="${fn:length(rows)}"/}<br/>
{c:forEach items="${rows[0]}" var="entry"}
{c:out value="${entry.key}=${entry.value}"}<br/>
{/c:forEach}
{sql:update var="affectedRows"}
UPDATE #__weblinks SET title = ? WHERE title = ?
{sql:param value="${oldTitle}"/}
{sql:param value="${newTitle}"/}
{/sql:update}
affected rows: {c:out value="${affectedRows}"/}<br/>
|
|