From: toyomoyo Date: Mon, 30 Jul 2007 04:36:05 +0000 (+0000) Subject: adding function get_fieldset_select() MDL-10181 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3e176d9de2318fb935828aad7e2c5a7097435d01;p=moodle.git adding function get_fieldset_select() MDL-10181 --- diff --git a/lib/dmllib.php b/lib/dmllib.php index 81d1271a30..a049ad5482 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -1077,6 +1077,23 @@ function get_field_sql($sql) { } } +/** + * Get a single value from a table row where a particular select clause is true. + * + * @uses $CFG + * @param string $table the table to query. + * @param string $return the field to return the value of. + * @param string $select A fragment of SQL to be used in a where clause in the SQL call. + * @return mixed|false Returns the value return from the SQL statment or false if an error occured. + */ +function get_fieldset_select($table, $return, $select) { + global $CFG; + if ($select) { + $select = ' WHERE '. $select; + } + return get_fieldset_sql('SELECT ' . $return . ' FROM ' . $CFG->prefix . $table . $select); +} + /** * Get an array of data from one or more fields from a database * use to get a column, or a series of distinct values