Riverwatcher Active Content Environment

RACE Documentation:


DATABASE HASH - Special database related variables in RACE



  • NEXT - Contains the value of the next row in the database.
  • HEADERS - Contains a list of all field names returned to the DATABASE tag.
  • FIELDS - Contains the number of field names returned to the DATABASE tag.
  • ROWS - Contains the number of rows returned thus far to the DATABASE tag.
  • VALUES - Contains the values of the fields listed in the HEADERS array.
  • ERROR - Contains any database error(s) that RACE has encountered.


Example - An example database hash dump
Source:

<database name="mysitedb" user="myusername" password="mysecretpassword" type="mysql" query="SELECT * FROM sessions">
  <%database><br><br>
</db>

Output:
next="1" headers=(SessionID,UserID,lastdate,lastpage) fields="6" rows="2" values=(lastpage="/funthings.race" lastdate="2003-05-26 08:38:22" UserID="1" SessionID="xo6yVEoIj61fE4aYrDy9fItevVkgGl6f0d2uGFeR") query="SELECT * FROM sessions" error=""

next="2" headers=(SessionID,UserID,lastdate,lastpage) fields="6" rows="2" values=(lastpage="/downloads/index.race" lastdate="2003-05-26 08:37:31" UserID="5" SessionID="XJMAIUyP4scvxkXdxPaBapIvMoi3aqqWYd6IV62") query="SELECT * FROM sessions" error=""


Example - Simplified DATABASE calls with error reporting
Source:

<define strip balanced tag="db">
  <database name="mydatabase" user="myusername" password="mysecretpassword" type="mysql" <%attributes>><$caller.body></database>
  <if test="<$database.error> != ''">
    <table border="1" bgcolor="#ff0000">
    <td>Database Error</td>
    <td><%database></td>
    </table>
  </if>
</define>

<db query="SELECT * FROM favoritecolors">
  <#name>, <#favoritecolor><br>
</db>

Output:
This same example from the ATTRIBUTES HASH section shows how create an easy to use database tag that displays a message if RACE encounters a database error.




RACE Documentation



 
Copyright 2009 Riverwatcher, Inc. Hosting by Riverwatcher Studios