[phpwebapp-commits] CVS: web_app/webobjects/form formWebObj.php,1.11,1.12 formWebObj.txt,1.5,1.6
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2006-01-31 08:06:39
|
Update of /cvsroot/phpwebapp/web_app/webobjects/form In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20311/webobjects/form Modified Files: formWebObj.php formWebObj.txt Log Message: Index: formWebObj.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/form/formWebObj.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** formWebObj.php 4 Jan 2006 08:32:38 -0000 1.11 --- formWebObj.php 31 Jan 2006 08:06:23 -0000 1.12 *************** *** 84,97 **** /** * $record is an associative array where keys are named after ! * the fields of the table. $key is the name of the primary key. * The function builds and executes a query that updates the * fields given in the $record (which includes the primary key as well). */ ! function update_record($record, $table, $key) ! { $record = $this->fix_record($record, $table); $values = $this->get_query_values($record); ! $val = $record[$key]; ! $query = "UPDATE $table\n SET\n $values\n WHERE $key = '$val'"; WebApp::execQuery($query); } --- 84,108 ---- /** * $record is an associative array where keys are named after ! * the fields of the table. $keys is the fields of the primary key. * The function builds and executes a query that updates the * fields given in the $record (which includes the primary key as well). */ ! function update_record($record, $table, $keys) ! { $record = $this->fix_record($record, $table); $values = $this->get_query_values($record); ! ! //build the WHERE condition of the primary key ! $arr_keys = explode(',', $keys); ! $arr_conditions = array(); ! for ($i=0; $i < sizeof($arr_keys); $i++) ! { ! $key = $arr_keys[$i]; ! $val = $record[$key]; ! $arr_conditions[] = "($key = '$val')"; ! } ! $condition = implode(' AND ', $arr_conditions); ! ! $query = "UPDATE $table\n SET\n $values\n WHERE $condition"; WebApp::execQuery($query); } *************** *** 163,174 **** * From the items of the given array create a listbox recordset * (with the fields 'id' and 'label'), and insert it in the $webPage. */ ! function add_listbox_rs($rs_id, $arr_labels) { $rs = new EditableRS($rs_id); ! for ($i=0; $i < sizeof($arr_labels); $i++) { ! $label = $arr_labels[$i]; ! $rs->addRec(array('id' => $label, 'label' => $label)); } global $webPage; --- 174,190 ---- * From the items of the given array create a listbox recordset * (with the fields 'id' and 'label'), and insert it in the $webPage. + * $arr_options can be an associated array, a simple array, or mixed. + * In case of the associated array, the keys are used as id-s and + * the values are used as labels. */ ! function add_listbox_rs($rs_id, $arr_options) { $rs = new EditableRS($rs_id); ! $arr_keys = array_keys($arr_options); ! for ($i=0; $i < sizeof($arr_keys); $i++) { ! $key = $arr_keys[$i]; ! $value = $arr_options[$key]; ! $rs->addRec(array('id' => $key, 'label' => $value)); } global $webPage; Index: formWebObj.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/form/formWebObj.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** formWebObj.txt 4 Jan 2006 08:32:38 -0000 1.5 --- formWebObj.txt 31 Jan 2006 08:06:23 -0000 1.6 *************** *** 94,96 **** --- 94,99 ---- * From the items of the given array create a listbox recordset * (with the fields 'id' and 'label'), and insert it in the $webPage. + * $arr_options can be an associated array, a simple array, or mixed. + * In case of the associated array, the keys are used as id-s and + * the values are used as labels. */ |