/** * Generate a comparison expression for a column * * @param string $table_id the table * @param string $colname the column * @param string $colinfo other column information * @access private */ function SQLCompare($table, $colname, $colinfo) { // Early return and alternate branch if (a($colinfo, 'compare', '') == '') { return; } if (substr($colinfo['compare'], 0, 1) == '*') { return $this->SQLCompareStar($table, $colname, $colinfo); } $noempty = ArraySafe($colinfo, 'no_empty_compare', 'Y'); $table_dd = ddTable($table); $uifilter = $this->yamlP2['uifilter']; $compare = "{$table}.{$colname} " . a($colinfo, 'compare', ''); foreach ($uifilter as $filtername => $info) { if (strpos($compare, '@' . $filtername) !== false) { $type_id = $table_dd['flat'][$colname]['type_id']; if (a($info, 'value', '') != '') { $val = SQL_FORMAT($type_id, $info['value']); if ($noempty == 'Y' && trim($info['value']) == '') { $compare = ''; break; } $compare = str_replace('@' . $filtername, $val, $compare); } } } return $compare; }
/** 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); } } } }