version 1.44, 2006/05/10 16:51:46 |
version 1.45, 2006/09/08 07:34:30 |
|
|
* http://platon.sk/projects/phpMyEdit/ |
* http://platon.sk/projects/phpMyEdit/ |
*/ |
*/ |
|
|
/* $Platon: phpMyEdit/phpMyEditSetup.php,v 1.41 2005/03/24 17:15:54 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEditSetup.php,v 1.44 2006-05-10 16:51:46 nepto Exp $ */ |
|
|
?> |
?> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
Line 101 function echo_buffer($x) |
|
Line 101 function echo_buffer($x) |
|
$buffer .= $x.PHP_EOL; |
$buffer .= $x.PHP_EOL; |
} |
} |
|
|
|
#:#####################################:# |
|
#:# Function: check_constraints #:# |
|
#:# Parameters: tb=table name #:# |
|
#:# fd=field name #:# |
|
#:# return: lookup default for #:# |
|
#:# said constraint #:# |
|
#:# or null if no #:# |
|
#:# constraint is found. #:# |
|
#:# Contributed by Wade Ryan, #:# |
|
#:# 20060906 #:# |
|
#:#####################################:# |
|
function check_constraints($tb,$fd) |
|
{ |
|
$query = "show create table $tb"; |
|
$result = mysql_query($query); |
|
$tableDef = preg_split('/\n/',mysql_result($result,0,1)); |
|
|
|
$constraint_arg=""; |
|
while (list($key,$val) = each($tableDef)) { |
|
$words=preg_split("/[\s'`()]+/", $val); |
|
if ($words[1] == "CONSTRAINT" && $words[6]=="REFERENCES") { |
|
if ($words[5]==$fd) { |
|
$constraint_arg=" 'values' => array(\n". |
|
" 'table' => '$words[7]',\n". |
|
" 'column' => '$words[8]'\n". |
|
" ),\n"; |
|
} |
|
|
|
} |
|
} |
|
return $constraint_arg; |
|
} |
|
|
|
|
$self = basename($_SERVER['PHP_SELF']); |
$self = basename($_SERVER['PHP_SELF']); |
$dbl = @mysql_pconnect($hn, $un, $pw); |
$dbl = @mysql_pconnect($hn, $un, $pw); |
|
|
Line 410 appear in generated list. Here are some |
|
Line 444 appear in generated list. Here are some |
|
} else if ($auto_increment) { |
} else if ($auto_increment) { |
echo_buffer(" 'default' => '0',"); |
echo_buffer(" 'default' => '0',"); |
} |
} |
|
// check for table constraints |
|
$outstr = check_constraints($tb, $fd); |
|
if ($outstr != '') { |
|
echo_buffer($outstr); |
|
} |
echo_buffer(" 'sort' => true"); |
echo_buffer(" 'sort' => true"); |
//echo_buffer(" 'nowrap' => false,"); |
//echo_buffer(" 'nowrap' => false,"); |
echo_buffer(');'); |
echo_buffer(');'); |