/** name:SQLX_Update parm:string/array table parm:array Row In its most basic form, this routine accepts a [[Row Array]] and attempts to update that row in the table. The first entry can be either a [[Table Reference]] or the name of a table. The second entry is always a [[Row Array]]. This function makes use of the dictionary to determine the correct formatting of all columns, and ignores any column in the [[Row Array]] that is not in the table. */ function SQLX_Update($table, $colvals, $errrow = array()) { if (!is_array($table)) { $table = DD_TableRef($table); } $table_id = $table["table_id"]; $view_id = DDTable_IDResolve($table_id); $tabflat =& $table["flat"]; $sql = ""; $st_skey = isset($colvals["skey"]) ? $colvals["skey"] : CleanGet("gp_skey"); foreach ($tabflat as $colname => $colinfo) { if (isset($colvals[$colname])) { if (DD_ColUpdatesOK($colinfo)) { $sql .= ListDelim($sql) . $colname . " = " . SQL_FORMAT($colinfo["type_id"], $colvals[$colname]); } } } if ($sql != '') { $sql = "UPDATE " . $view_id . " SET " . $sql . " WHERE skey = " . $st_skey; // ERRORROW CHANGE 5/30/07, big change, SQLX_* routines now save // the row for the table if there was an error $errflag = false; #hprint_r($sql); SQL($sql, $errflag); if ($errflag) { vgfSet('ErrorRow_' . $table_id, $errrow); } // Possibly cache the row if (!Errors()) { $cache_pkey0 = vgfget('cache_pkey', array()); $cache_pkey = array_flip($cache_pkey0); if (isset($cache_pkey[$table_id])) { CacheRowPutBySkey($table, $st_skey); } } } }
function HTMLX_Notices() { global $AG; $retval = ""; foreach ($AG["messages"] as $err) { $retval .= ListDelim($retval, "<br><br>") . $err . "\n"; } $AG["messages"] = array(); if ($retval == "") { return ""; } else { return $retval; } }
function aLinks_DrillDown($mode) { if ($mode != 'upd') { return array(); } if ($this->table_id_parent != '') { return array(); } $retval = array(); // Get the pks into a string value, do the loop so we can trim $lpks = $this->table['pks']; $apks = explode(",", $lpks); $lpkvals = ''; foreach ($apks as $colname) { $lpkvals .= ListDelim($lpkvals) . trim($this->row[$colname]); } $dd = array('drilldown', 'mover'); foreach ($this->children as $table_id => $tabinfo) { if (!in_array($tabinfo['display'], $dd)) { continue; } $tabdesc = DD_TableProperty($table_id, 'description'); $h = hLinkPostFromArray('', $tabdesc, array('gp_dd_page' => $table_id)); //$js = "drillDown('$table_id','$lpks','$lpkvals')"; $retval[] = $h; } return $retval; }