SourceForge.net Logo
Home | SourceForge | Documentation | FAQ | What's New | To-Do List | Forums | Download | Contact

sqltemplate Tag

Attribute List:

This tag encloses an entire template. It provides the basic information about the type of template you want it to be, as well as the query info. All attributes (unless specified) are relevant to all template types.

Type of tag: Open/close

Attributes

type


Required: Yes
Values: display | edit | add | mass-edit
Default: display

Indicates what kind of template you want to show. Display will only display values, nothing else. Edit will allow the user to edit or delete values (see the SQLAction tag for info on how to differentiate between allowing the user to edit each row separately or all rows at once). Add will allow the user to insert a new row into tables, but not to see existing ones.
Note that if you use the query attribute, type will automatically be set to display (i.e. this attribute will be ignored).
Mass-edit is not required for regular templates (Sparse will change edit types to mass-edit types if it detects an update button outside the sqlrow tag) but is required for quick templates.

database


Required: No
Values: A valid database

Similar to the "use db;" command in mySQL, this selects the default database for the query. It's not required if you pass a MySQL connection directly to Sparse when you call SparseThisPage() or SparsePage().

tables


Required: Only if query is not set
Values: The "table_references" for your SQL query.

Simple enough, just list the tables you want to deal with. You can use the AS keyword for aliases, and can separate the tables by commas or JOIN keywords etc.

query


Required: Only if tables is not set
Values: Any valid SQL query

You can create a template with a direct query using this attribute. This allows for very complex queries, but the advanced functionality won't be available - you can only use a display template.

limit


Required: No
Values: An integer number greater than 1. Note that this does not support "LIMIT 10, 15" syntax.

This will allow you to limit the number of rows you want to display. In other words, this is the number of rows which will be displayed per page. You can add "Previous/Next" buttons using the sqlaction tag to allow the user to navigate around the rows. Note that this attribute can be used even if you have a query rather than table defined.

constraints


Required: No
Values: Any valid WHERE/ORDER BY/GROUP BY/HAVING clause (all together).

This is the remainder of the query. See Templates And Queries for more info. This attribute is ignored if you have a query rather than table defined.

rowsToAdd


Required: No
Values: Valid positive integer

For add templates, which have no data, you can indicate how many new rows the user can insert at once by setting this attribute (e.g. if rowsToAdd is 5, the user will be shown 5 rows to insert). By default this is 1.

deleteTables


Required: No
Values: A comma-delineated list of table aliases

If your query has multiple tables, deleting a row from the template will delete the row from each of the tables. To avoid this behavior, put a list of tables in this attribute; only these tables will have their rows deleted. Note that you should use the resolved name of the table; if you used an alias to define the table, use the alias here.