| version 1.146, 2004/07/15 10:40:19 |
version 1.147, 2004/07/15 13:41:14 |
|
|
| * http://platon.sk/projects/phpMyEdit/ |
* http://platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.145 2004/07/13 17:59:33 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.146 2004/07/15 10:40:19 nepto Exp $ */ |
| |
|
| /* This is a generic table editing program. The table and fields to be |
/* This is a generic table editing program. The table and fields to be |
| edited are defined in the calling program. |
edited are defined in the calling program. |
|
|
| var $hn; // hostname |
var $hn; // hostname |
| var $un; // user name |
var $un; // user name |
| var $pw; // password |
var $pw; // password |
| var $db; // database |
|
| var $tb; // table |
var $tb; // table |
| |
var $db; // database |
| |
var $dbp; // database with point |
| 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 |
| |
|
|
|
| $line = intval($line); |
$line = intval($line); |
| echo '<h4>MySQL query at line ',$line,'</h4>',htmlspecialchars($qry),'<hr>',"\n"; |
echo '<h4>MySQL query at line ',$line,'</h4>',htmlspecialchars($qry),'<hr>',"\n"; |
| } |
} |
| $ret = @mysql_db_query($this->db, $qry, $this->dbh); |
if (isset($this->db)) { |
| |
$ret = @mysql_db_query($this->db, $qry, $this->dbh); |
| |
} else { |
| |
$ret = @mysql_query($qry, $this->dbh); |
| |
} |
| if (! $ret) { |
if (! $ret) { |
| echo '<h4>MySQL error ',mysql_errno($this->dbh),'</h4>'; |
echo '<h4>MySQL error ',mysql_errno($this->dbh),'</h4>'; |
| echo htmlspecialchars(mysql_error($this->dbh)),'<hr>',"\n"; |
echo htmlspecialchars(mysql_error($this->dbh)),'<hr>',"\n"; |
|
|
| $table = &$this->fdd[$field_num]['values']['table']; |
$table = &$this->fdd[$field_num]['values']['table']; |
| $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']; |
| isset($db) || $db = $this->db; |
$dbp = isset($db) ? "$db." : $this->dbp; |
| $qparts['type'] = 'select'; |
$qparts['type'] = 'select'; |
| if ($table) { |
if ($table) { |
| $qparts['select'] = 'DISTINCT '.$table.'.'.$key; |
$qparts['select'] = 'DISTINCT '.$table.'.'.$key; |
|
|
| } else if ($key) { |
} else if ($key) { |
| $qparts['orderby'] = $key; |
$qparts['orderby'] = $key; |
| } |
} |
| //$qparts['from'] = "$db.$table.$sel; |
$qparts['from'] = "$dbp$table"; |
| $qparts['from'] = "$db.$table"; |
|
| $qparts['where'] = $this->fdd[$field_num]['values']['filters']; |
$qparts['where'] = $this->fdd[$field_num]['values']['filters']; |
| if ($this->fdd[$field_num]['values']['orderby']) { |
if ($this->fdd[$field_num]['values']['orderby']) { |
| $qparts['orderby'] = $this->fdd[$field_num]['values']['orderby']; |
$qparts['orderby'] = $this->fdd[$field_num]['values']['orderby']; |
|
|
| $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 '.$key.' AS PMEkey'; |
| $qparts['orderby'] = 'PMEkey'; |
$qparts['orderby'] = 'PMEkey'; |
| $qparts['from'] = $this->db.'.'.$this->tb; |
$qparts['from'] = $this->dbp.$this->tb; |
| } |
} |
| $values = array(); |
$values = array(); |
| $res = $this->myquery($this->query_make($qparts), __LINE__); |
$res = $this->myquery($this->query_make($qparts), __LINE__); |
|
|
| 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']) { |
| $db = $this->fdd[$main_column]['values']['db']; |
$dbp = $this->fdd[$main_column]['values']['db'].'.'; |
| } else { |
} else { |
| $db = $this->db; |
$dbp = $this->dbp; |
| } |
} |
| $table = @$this->fdd[$main_column]['values']['table']; |
$table = @$this->fdd[$main_column]['values']['table']; |
| $join_column = @$this->fdd[$main_column]['values']['column']; |
$join_column = @$this->fdd[$main_column]['values']['column']; |
|
|
| '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 $db.$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.$main_column"; |
| Line 1563 function phpMyEdit_filter_handler(theFor |
|
| Line 1567 function phpMyEdit_filter_handler(theFor |
|
| echo 'un=',$this->un,' '; |
echo 'un=',$this->un,' '; |
| echo 'pw=',$this->pw,' '; |
echo 'pw=',$this->pw,' '; |
| echo 'db=',$this->db,' '; |
echo 'db=',$this->db,' '; |
| |
echo 'dbp=',$this->dbp,' '; |
| |
echo 'dbh=',$this->dbh,' '; |
| echo 'tb=',$this->tb,' '; |
echo 'tb=',$this->tb,' '; |
| echo 'key=',$this->key,' '; |
echo 'key=',$this->key,' '; |
| echo 'key_type=',$this->key_type,' '; |
echo 'key_type=',$this->key_type,' '; |
| Line 2557 function phpMyEdit_filter_handler(theFor |
|
| Line 2563 function phpMyEdit_filter_handler(theFor |
|
| $body .= "\n--\r\n"; // \r is needed for signature separating |
$body .= "\n--\r\n"; // \r is needed for signature separating |
| $body .= "phpMyEdit\ninstant MySQL table editor and code generator\n"; |
$body .= "phpMyEdit\ninstant MySQL table editor and code generator\n"; |
| $body .= "http://www.platon.sk/projects/phpMyEdit/\n\n"; |
$body .= "http://www.platon.sk/projects/phpMyEdit/\n\n"; |
| $subject = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb; |
$subject = @$this->notify['prefix'].$subject.' '.$this->dbp.$this->tb; |
| $subject = trim($subject); // just for sure |
$subject = trim($subject); // just for sure |
| $wrap_w = intval(@$this->notify['wrap']); |
$wrap_w = intval(@$this->notify['wrap']); |
| $wrap_w > 0 || $wrap_w = 72; |
$wrap_w > 0 || $wrap_w = 72; |
| Line 2888 function phpMyEdit_filter_handler(theFor |
|
| Line 2894 function phpMyEdit_filter_handler(theFor |
|
| if (isset($opts['dbh'])) { |
if (isset($opts['dbh'])) { |
| $this->close_dbh = false; |
$this->close_dbh = false; |
| $this->dbh = $opts['dbh']; |
$this->dbh = $opts['dbh']; |
| |
$this->dbp = ''; |
| } else { |
} else { |
| $this->close_dbh = true; |
$this->close_dbh = true; |
| $this->dbh = null; |
$this->dbh = null; |
| |
$this->dbp = $opts['db'].'.'; |
| $this->hn = $opts['hn']; |
$this->hn = $opts['hn']; |
| $this->un = $opts['un']; |
$this->un = $opts['un']; |
| $this->pw = $opts['pw']; |
$this->pw = $opts['pw']; |
| $this->db = $opts['db']; |
$this->db = $opts['db']; |
| $this->tb = $opts['tb']; |
|
| } |
} |
| |
$this->tb = $opts['tb']; |
| // Other variables |
// Other variables |
| $this->key = $opts['key']; |
$this->key = $opts['key']; |
| $this->key_type = $opts['key_type']; |
$this->key_type = $opts['key_type']; |