template::util::is_unique (public)
template::util::is_unique table columns values
Defined in packages/acs-templating/tcl/util-procs.tcl
Queries a database table for the existence of a particular row. Useful for validating form input to reduce the possibility of unique constraint violations.
- Parameters:
- table (required)
- The name of a database table.
- columns (required)
- A list of columns on which to select the row.
- values (required)
- A list of values for each specified column.
- Returns:
- 1 if the row exists, 0 if not
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set query "select count(*) from $table where " for { set i 0 } { $i < [llength $columns] } { incr i } { set value [ns_dbquotevalue [lindex $values $i]] lappend conditions "[lindex $columns $i] = $value" } append query [join $conditions " and "] set count [db_string get_count $query] return [expr {$count == 0}]XQL Not present: Generic, PostgreSQL, Oracle