| General Plugin info | |
|---|---|
| Author: | nullibicity |
| Current Version: | 01 |
| Download: | - |
| Code: | - |
| Demo: | - |
| Forum Thread: | this forum topic |
This plugin lets you run commands on SQL queries via plugin parameters. It might be good for testing out plugin ideas or replacing a set of smaller plugins.
Use this in your skin like this: <%Plugin(CustomQuery, query, command)%>, where query and command are quoted PHP strings (see examples). The command is optional – <%Plugin(CustomQuery, query)%> will just echo the first column returned, followed by a break tag.
Due to the way Nucleus parses plugin parameters – it would be nice if a future version would ignore commas in quotes – commas within the query or command strings must be replaced with ”,”. A few global variables are provided; I wasn't sure which ones might be needed (does Nucleus provide an array of globals like PHP does?). Elements returned by the SQL query can be referenced by index or column name, e.g., $row[0] or $row[ititle].
Number of Members:
<%Plugin(CustomQuery,”SELECT count(mnumber) FROM ”.sql_table('member'))%>
Member List:
<%Plugin(CustomQuery,”SELECT mname,mrealname FROM ”.sql_table('member').” ORDER BY mname”, echo “$row[mname] ($row[mrealname])<br />”;)%>
Number of Published Entries in Current Blog:
<%Plugin(CustomQuery,”SELECT count(inumber) FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()))%> Alphabetical List of Published Entries in Current Blog:
<%Plugin(CustomQuery,”SELECT ititle,inumber FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()).” ORDER BY ititle”, echo ”<a href=\””.$blog→getURL.createItemLink($row[inumber], ).”\”>$row[ititle]</a><br />”;)%>
Random Entry:
<%Plugin(CustomQuery,”SELECT ititle,inumber FROM ”.sql_table('item').” WHERE iblog=”.$blog→getID().” AND idraft=0 AND itime⇐”.mysqldate($blog→getCorrectTime()).” ORDER BY rand() LIMIT 1”, echo ”<a href=\””.$blog→getURL.createItemLink($row[inumber], ).”\”>$row[ititle]</a><br />”;)%>