• RSS 0.91
  • RSS 1.0
  • RSS 2.0
  • ATOM 0.3
  • OPML

Logic-SQL

The following SQL-Moslates are the implementation of some SQL-Tags specified by the JSTL.
(To use those, you need to import logic_export)

logic-sql
nameoutputcode
sql:query
var(default:rows),
scope(optional),
sql(optional)


... ? ... : ...

accessing properties
rows (5)
0 Joomla
http://www.joomla.org
1 OSM
http://www.opensourcematters.org
2 php.net
http://www.php.net
3 MySQL
http://www.mysql.com
4 Joomla Developer
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/>