version 1.192, 2007/04/11 20:06:35 |
version 1.193, 2007/04/13 10:34:56 |
|
|
var $pw; // password |
var $pw; // password |
var $tb; // table |
var $tb; // table |
var $db; // database |
var $db; // database |
var $dbp; // database with point |
var $dbp; // database with point and delimiters |
var $dbh; // database handle |
var $dbh; // database handle |
var $close_dbh; // if database handle should be closed |
var $close_dbh; // if database handle should be closed |
|
|
|
|
function set_values_from_table($field_num, $strict = false) /* {{{ */ |
function set_values_from_table($field_num, $strict = false) /* {{{ */ |
{ |
{ |
$db = &$this->fdd[$field_num]['values']['db']; |
$db = &$this->fdd[$field_num]['values']['db']; |
$table = &$this->fdd[$field_num]['values']['table']; |
$table = $this->sd.$this->fdd[$field_num]['values']['table'].$this->ed; |
$key = &$this->fdd[$field_num]['values']['column']; |
$key = &$this->fdd[$field_num]['values']['column']; |
$desc = &$this->fdd[$field_num]['values']['description']; |
$desc = &$this->fdd[$field_num]['values']['description']; |
$dbp = isset($db) ? "$db." : $this->dbp; |
$dbp = isset($db) ? $this->sd.$db.$this->ed.'.' : $this->dbp; |
$qparts['type'] = 'select'; |
$qparts['type'] = 'select'; |
if ($table) { |
if ($table != $this->sd.$this->ed) { |
$qparts['select'] = 'DISTINCT '.$table.'.'.$key; |
$qparts['select'] = 'DISTINCT '.$table.'.'.$this->sd.$key.$this->ed; |
if ($desc && is_array($desc) && is_array($desc['columns'])) { |
if ($desc && is_array($desc) && is_array($desc['columns'])) { |
$qparts['select'] .= ',CONCAT('; // ) |
$qparts['select'] .= ',CONCAT('; // ) |
$num_cols = sizeof($desc['columns']); |
$num_cols = sizeof($desc['columns']); |
|
|
} |
} |
foreach ($desc['columns'] as $key => $val) { |
foreach ($desc['columns'] as $key => $val) { |
if ($val) { |
if ($val) { |
$qparts['select'] .= 'IFNULL('.$val.',"")'; |
$qparts['select'] .= 'IFNULL('.$this->sd.$val.$this->ed.',"")'; |
if ($desc['divs'][$key]) { |
if ($desc['divs'][$key]) { |
$qparts['select'] .= ',"'.addslashes($desc['divs'][$key]).'"'; |
$qparts['select'] .= ',"'.addslashes($desc['divs'][$key]).'"'; |
} |
} |
|
|
} |
} |
} |
} |
$qparts['select']{strlen($qparts['select']) - 1} = ')'; |
$qparts['select']{strlen($qparts['select']) - 1} = ')'; |
$qparts['select'] .= ' AS PMEalias'.$field_num; |
$qparts['select'] .= ' AS '.$this->sd.'PMEalias'.$field_num.$this->ed; |
$qparts['orderby'] = 'PMEalias'.$field_num; |
$qparts['orderby'] = $this->sd.'PMEalias'.$field_num.$this->ed; |
} else if ($desc && is_array($desc)) { |
} else if ($desc && is_array($desc)) { |
// TODO |
// TODO |
} else if ($desc) { |
} else if ($desc) { |
$qparts['select'] .= ','.$table.'.'.$desc; |
$qparts['select'] .= ','.$table.'.'.$this->sd.$desc.$this->ed; |
$qparts['orderby'] = $desc; |
$qparts['orderby'] = $this->sd.$desc.$this->ed; |
} else if ($key) { |
} else if ($key) { |
$qparts['orderby'] = $key; |
$qparts['orderby'] = $this->sd.$key.$this->ed; |
} |
} |
$qparts['from'] = "$dbp$table"; |
$qparts['from'] = $dbp.$table; |
$ar = array( |
$ar = array( |
'table' => $table, |
'table' => $table, |
'column' => $column, |
'column' => $column, |
|
|
} else { /* simple value extraction */ |
} else { /* simple value extraction */ |
$key = &$this->fds[$field_num]; |
$key = &$this->fds[$field_num]; |
$this->virtual($field_num) && $key = $this->fqn($field_num); |
$this->virtual($field_num) && $key = $this->fqn($field_num); |
$qparts['select'] = 'DISTINCT '.$key.' AS PMEkey'; |
$qparts['select'] = 'DISTINCT '.$this->sd.$key.$this->ed.' AS PMEkey'; |
$qparts['orderby'] = 'PMEkey'; |
$qparts['orderby'] = 'PMEkey'; |
$qparts['from'] = $this->dbp.$this->tb; |
$qparts['from'] = $this->dbp.$this->sd.$this->tb.$this->ed; |
} |
} |
$values = array(); |
$values = array(); |
$res = $this->myquery($this->get_SQL_query($qparts), __LINE__); |
$res = $this->myquery($this->get_SQL_query($qparts), __LINE__); |
|
|
if ($this->add_operation() |
if ($this->add_operation() |
|| $this->copy_operation() |
|| $this->copy_operation() |
|| $this->change_operation()) { |
|| $this->change_operation()) { |
$ret = 'PMEtable0.'.$this->sd.$this->fds[$field].$this->ed; |
$ret = $this->sd.'PMEtable0'.$this->ed.'.'.$this->sd.$this->fds[$field].$this->ed; |
} else { |
} else { |
if ($this->fdd[$this->fds[$field]]['values']['description'] && ! $dont_desc) { |
if ($this->fdd[$this->fds[$field]]['values']['description'] && ! $dont_desc) { |
$desc = &$this->fdd[$this->fds[$field]]['values']['description']; |
$desc = &$this->fdd[$this->fds[$field]]['values']['description']; |
|
|
} |
} |
foreach ($desc['columns'] as $key => $val) { |
foreach ($desc['columns'] as $key => $val) { |
if ($val) { |
if ($val) { |
$ret .= 'PMEjoin'.$field.'.'.$val; |
$ret .= $this->sd.'PMEjoin'.$field.$this->ed.'.'.$this->sd.$val.$this->ed; |
if ($desc['divs'][$key]) { |
if ($desc['divs'][$key]) { |
$ret .= ',"'.addslashes($desc['divs'][$key]).'"'; |
$ret .= ',"'.addslashes($desc['divs'][$key]).'"'; |
} |
} |
|
|
} else if (is_array($desc)) { |
} else if (is_array($desc)) { |
// TODO |
// TODO |
} else { |
} else { |
$ret = 'PMEjoin'.$field.'.'.$this->fdd[$this->fds[$field]]['values']['description']; |
$ret = 'PMEjoin'.$field.'.'.$this->sd.$this->fdd[$this->fds[$field]]['values']['description'].$this->ed; |
} |
} |
// TODO: remove me |
// TODO: remove me |
} elseif (0 && $this->fdd[$this->fds[$field]]['values']['column'] && ! $dont_cols) { |
} elseif (0 && $this->fdd[$this->fds[$field]]['values']['column'] && ! $dont_cols) { |
$ret = 'PMEjoin'.$field.'.'.$this->fdd[$this->fds[$field]]['values']['column']; |
$ret = 'PMEjoin'.$field.'.'.$this->fdd[$this->fds[$field]]['values']['column']; |
} else { |
} else { |
$ret = 'PMEtable0.'.$this->sd.$this->fds[$field].$this->ed; |
$ret = $this->sd.'PMEtable0'.$this->ed.'.'.$this->sd.$this->fds[$field].$this->ed; |
} |
} |
// TODO: not neccessary, remove me! |
// TODO: not neccessary, remove me! |
if (is_array($this->fdd[$this->fds[$field]]['values2'])) { |
if (is_array($this->fdd[$this->fds[$field]]['values2'])) { |
|
|
if (! $this->displayed[$k] && $k != $this->key_num) { |
if (! $this->displayed[$k] && $k != $this->key_num) { |
continue; |
continue; |
} |
} |
$fields[] = $this->fqn($k).' AS qf'.$k; // no delimiters here |
$fields[] = $this->fqn($k).' AS '.$this->sd.'qf'.$k.$this->ed; // no delimiters here, or maybe some yes |
if ($this->col_has_values($k)) { |
if ($this->col_has_values($k)) { |
$fields[] = $this->fqn($k, true, true).' AS qf'.$k.'_idx'; |
$fields[] = $this->fqn($k, true, true).' AS '.$this->sd.'qf'.$k.'_idx'.$this->ed; |
} |
} |
if ($this->col_has_datemask($k)) { |
if ($this->col_has_datemask($k)) { |
$fields[] = 'UNIX_TIMESTAMP('.$this->fqn($k).') AS qf'.$k.'_timestamp'; |
$fields[] = 'UNIX_TIMESTAMP('.$this->fqn($k).') AS '.$this->sd.'qf'.$k.'_timestamp'.$this->ed; |
} |
} |
} |
} |
return join(',', $fields); |
return join(',', $fields); |
|
|
|
|
function get_SQL_join_clause() /* {{{ */ |
function get_SQL_join_clause() /* {{{ */ |
{ |
{ |
$main_table = 'PMEtable0'; |
$main_table = $this->sd.'PMEtable0'.$this->ed; |
$join_clause = $this->tb." AS $main_table"; |
$join_clause = $this->sd.$this->tb.$this->ed." AS $main_table"; |
for ($k = 0, $numfds = sizeof($this->fds); $k < $numfds; $k++) { |
for ($k = 0, $numfds = sizeof($this->fds); $k < $numfds; $k++) { |
$main_column = $this->fds[$k]; |
$main_column = $this->fds[$k]; |
if($this->fdd[$main_column]['values']['db']) { |
if($this->fdd[$main_column]['values']['db']) { |
$dbp = $this->fdd[$main_column]['values']['db'].'.'; |
$dbp = $this->sd.$this->fdd[$main_column]['values']['db'].$this->ed.'.'; |
} else { |
} else { |
$dbp = $this->dbp; |
$dbp = $this->dbp; |
} |
} |
$table = @$this->fdd[$main_column]['values']['table']; |
$table = $this->sd.$this->fdd[$main_column]['values']['table'].$this->ed; |
$join_column = @$this->fdd[$main_column]['values']['column']; |
$join_column = $this->sd.$this->fdd[$main_column]['values']['column'].$this->ed; |
$join_desc = @$this->fdd[$main_column]['values']['description']; |
$join_desc = $this->sd.$this->fdd[$main_column]['values']['description'].$this->ed; |
if ($join_desc != '' && $join_column != '') { |
if ($join_desc != $this->sd.$this->ed && $join_column != $this->sd.$this->ed) { |
$join_table = 'PMEjoin'.$k; |
$join_table = $this->sd.'PMEjoin'.$k.$this->ed; |
$ar = array( |
$ar = array( |
'main_table' => $main_table, |
'main_table' => $main_table, |
'main_column' => $main_column, |
'main_column' => $this->sd.$main_column.$this->ed, |
'join_table' => $join_table, |
'join_table' => $join_table, |
'join_column' => $join_column, |
'join_column' => $join_column, |
'join_description' => $join_desc); |
'join_description' => $join_desc); |
$join_clause .= " LEFT OUTER JOIN $dbp$table AS $join_table ON ("; |
$join_clause .= " LEFT OUTER JOIN $dbp".$table." AS $join_table ON ("; |
$join_clause .= isset($this->fdd[$main_column]['values']['join']) |
$join_clause .= isset($this->fdd[$main_column]['values']['join']) |
? $this->substituteVars($this->fdd[$main_column]['values']['join'], $ar) |
? $this->substituteVars($this->fdd[$main_column]['values']['join'], $ar) |
: "$join_table.$join_column = $main_table.$main_column"; |
: "$join_table.$join_column = $main_table.".$this->sd.$main_column.$this->ed; |
if (isset($this->fdd[$main_column]['values']['filters'])) { |
if (isset($this->fdd[$main_column]['values']['filters'])) { |
$join_clause .= ' AND '; |
$join_clause .= ' AND '; |
$join_clause .= $this->substituteVars($this->fdd[$main_column]['values']['filters'], $ar); |
$join_clause .= $this->substituteVars($this->fdd[$main_column]['values']['filters'], $ar); |
Line 3107 function '.$this->js['prefix'].'filter_h |
|
Line 3107 function '.$this->js['prefix'].'filter_h |
|
if ($this->connect() == false) { |
if ($this->connect() == false) { |
return false; |
return false; |
} |
} |
$this->sql_delimiter(); |
|
|
|
/* |
/* |
* ====================================================================== |
* ====================================================================== |
Line 3196 function '.$this->js['prefix'].'filter_h |
|
Line 3195 function '.$this->js['prefix'].'filter_h |
|
// Set desirable error reporting level |
// Set desirable error reporting level |
$error_reporting = error_reporting(E_ALL & ~E_NOTICE); |
$error_reporting = error_reporting(E_ALL & ~E_NOTICE); |
// Database handle variables |
// Database handle variables |
|
$this->sql_delimiter(); |
if (isset($opts['dbh'])) { |
if (isset($opts['dbh'])) { |
$this->close_dbh = false; |
$this->close_dbh = false; |
$this->dbh = $opts['dbh']; |
$this->dbh = $opts['dbh']; |
Line 3203 function '.$this->js['prefix'].'filter_h |
|
Line 3203 function '.$this->js['prefix'].'filter_h |
|
} else { |
} else { |
$this->close_dbh = true; |
$this->close_dbh = true; |
$this->dbh = null; |
$this->dbh = null; |
$this->dbp = $opts['db'].'.'; |
$this->dbp = $this->sd.$opts['db'].$this->ed.'.'; |
$this->hn = $opts['hn']; |
$this->hn = $opts['hn']; |
$this->un = $opts['un']; |
$this->un = $opts['un']; |
$this->pw = $opts['pw']; |
$this->pw = $opts['pw']; |
Line 3377 function '.$this->js['prefix'].'filter_h |
|
Line 3377 function '.$this->js['prefix'].'filter_h |
|
* vim600:fdm=marker fdl=0 fdc=0: |
* vim600:fdm=marker fdl=0 fdc=0: |
* }}} */ |
* }}} */ |
|
|
?> |
|
|
|
|
?> |