version 1.30, 2002/11/22 00:21:49 |
version 1.31, 2002/11/22 12:48:46 |
|
|
* http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
*/ |
*/ |
|
|
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.29 2002/11/18 20:49:30 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.30 2002/11/22 00:21:49 nepto Exp $ */ |
|
|
/* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
/* |
/* |
|
|
var $pw; // password |
var $pw; // password |
var $db; // database |
var $db; // database |
var $tb; // table |
var $tb; // table |
|
var $dbh; // database handle |
|
|
var $key; // Name of field which is the unique key |
var $key; // Name of field which is the unique key |
var $key_type; // Type of key field (int/real/string/date etc) |
var $key_type; // Type of key field (int/real/string/date etc) |
|
|
echo '<h4>MySQL query at line '.$line.'</h4>'.htmlspecialchars($qry).'<hr>'."\n"; |
echo '<h4>MySQL query at line '.$line.'</h4>'.htmlspecialchars($qry).'<hr>'."\n"; |
} |
} |
$this->elog("qry: $qry",$line); |
$this->elog("qry: $qry",$line); |
$ret = @mysql_db_query($this->db, $qry); |
$ret = @mysql_db_query($this->db, $qry, $this->dbh); |
if (! $ret) { |
if (! $ret) { |
$this->elog(mysql_errno().": ".mysql_error().' in '.$qry,__LINE__); |
$this->elog(mysql_errno($this->dbh).': '.mysql_error($this->dbh).' in '.$qry, __LINE__); |
} |
} |
return $ret; |
return $ret; |
} /* }}} */ |
} /* }}} */ |
Line 1701 function form_control(theForm) |
|
Line 1702 function form_control(theForm) |
|
echo '<td colspan='.$sys_cols.' align="center">'; |
echo '<td colspan='.$sys_cols.' align="center">'; |
echo '<input type="submit" name="filter" value="' |
echo '<input type="submit" name="filter" value="' |
.$this->labels['Query'].'" /></td>'."\n"; |
.$this->labels['Query'].'" /></td>'."\n"; |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($kk = $k = 0; $k < $this->num_fds; $k++) { |
$this->field_name = $this->fds[$k]; |
$this->field_name = $this->fds[$k]; |
$fd = $this->field_name; |
$fd = $this->field_name; |
$this->field = $this->fdd[$fd]; |
$this->field = $this->fdd[$fd]; |
Line 1738 function form_control(theForm) |
|
Line 1739 function form_control(theForm) |
|
if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
continue; |
continue; |
} |
} |
|
$kk++; // $kk counts only displayed fields |
|
|
if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { |
if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { |
/* |
/* |
* Multiple fields processing - default size is 2 and array required for values |
* Multiple fields processing - default size is 2 and array required for values |
Line 1752 function form_control(theForm) |
|
Line 1755 function form_control(theForm) |
|
// this is where we put the comparison selects |
// this is where we put the comparison selects |
if (! $this->password($k) && ! $this->hidden($k)) { |
if (! $this->password($k) && ! $this->hidden($k)) { |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$maxlen = intval($this->fdd[$k]['maxlen']); |
!$maxlen && $maxlen = mysql_field_len($res, "qf$k"); |
!$maxlen && $maxlen = intval(@mysql_field_len($res, $kk /* "qf$k" */)); |
$size = $maxlen < 30 ? min($maxlen, 8) : 12; |
$size = $maxlen < 30 ? min(max(1, $maxlen), 8) : 12; |
if ($this->col_is_string($k)) { |
if ($this->col_is_string($k)) { |
// it's treated as a string |
// it's treated as a string |
echo '<input type="text" name="qf'.$k.'"'; |
echo '<input type="text" name="qf'.$k.'"'; |
Line 2316 function form_control(theForm) |
|
Line 2319 function form_control(theForm) |
|
if ($res) { |
if ($res) { |
$tim = true; |
$tim = true; |
} |
} |
$this->message = @mysql_affected_rows().' '.$this->labels['record added']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added']; |
} |
} |
if ( |
if ( |
$tib && |
$tib && |
Line 2415 function form_control(theForm) |
|
Line 2418 function form_control(theForm) |
|
$qry_old_rec .= ' FROM '.$this->tb.' WHERE ('.$this->key.' = '.$this->key_delim.$this->rec.$this->key_delim.')'; |
$qry_old_rec .= ' FROM '.$this->tb.' WHERE ('.$this->key.' = '.$this->key_delim.$this->rec.$this->key_delim.')'; |
// get the old data |
// get the old data |
$res_old = $this->myquery($qry_old_rec, __LINE__); |
$res_old = $this->myquery($qry_old_rec, __LINE__); |
$oldvalues = mysql_fetch_array($res_old); |
$oldvalues = @mysql_fetch_array($res_old); |
// update the data |
// update the data |
//echo "\n<h4>$qry</h4>\n"; |
//echo "\n<h4>$qry</h4>\n"; |
$res = $this->myquery($qry,__LINE__); |
$res = $this->myquery($qry,__LINE__); |
Line 2449 echo '<h3>Changes to be sent in e-mail:< |
|
Line 2452 echo '<h3>Changes to be sent in e-mail:< |
|
echo '<pre>'; |
echo '<pre>'; |
print_r($changes); |
print_r($changes); |
echo '</pre>'."\n"; |
echo '</pre>'."\n"; |
echo '<h5>'.mysql_affected_rows ().' '.$this->labels['Change'].'</h5>'."\n"; |
echo '<h5>'.@mysql_affected_rows($this->dbh).' '.$this->labels['Change'].'</h5>'."\n"; |
*/ |
*/ |
|
|
$this->message = @mysql_affected_rows().' '.$this->labels['record changed']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed']; |
} |
} |
if ( |
if ( |
$tub && |
$tub && |
Line 2538 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
Line 2541 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
if ($res) { |
if ($res) { |
$tdm = true; |
$tdm = true; |
} |
} |
$this->message = @mysql_affected_rows().' '.$this->labels['record deleted']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted']; |
} |
} |
if ( |
if ( |
$tdb && |
$tdb && |
Line 2734 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
Line 2737 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
return false; |
return false; |
} |
} |
|
|
if ($dbl = @mysql_pconnect($this->hn, $this->un, $this->pw)) ; |
if ($this->dbh = @mysql_pconnect($this->hn, $this->un, $this->pw)) ; |
else { |
else { |
$this->error('could not connect to MySQL'); |
$this->error('could not connect to MySQL'); |
return false; |
return false; |
Line 2744 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
Line 2747 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
} /* }}} */ |
} /* }}} */ |
|
|
/* |
/* |
|
* Database disconnection function |
|
*/ |
|
function disconnect() /* {{{ */ |
|
{ |
|
@mysql_close($this->dbh); |
|
} /* }}} */ |
|
|
|
/* |
* The workhorse |
* The workhorse |
*/ |
*/ |
function execute() /* {{{ */ |
function execute() /* {{{ */ |
Line 2816 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
Line 2827 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
$this->list_table(); |
$this->list_table(); |
} |
} |
|
|
|
$this->disconnect(); |
|
|
global $phpMyEdit_timer; |
global $phpMyEdit_timer; |
if ($this->display['time'] && $phpMyEdit_timer) { |
if ($this->display['time'] && $phpMyEdit_timer) { |
echo $phpMyEdit_timer->end(); |
echo $phpMyEdit_timer->end(); |