About 16,970 results: "php ksort"
Page 1 of 50
Filter Results
Sources
Languages
Filter Results
Try Search On







  1. array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU','',$f->result("SHOW CREATE VIEW ".table($D),1)));}function
  2. collations(){$J=array();foreach(get_rows("SHOW COLLATION")as$K){if($K["Default"])$J[$K["Charset"]][-1]=$K["Collation"];else$J[$K["Charset"]][]=$K["Collation"];}ksort($J);foreach($J
  3. as$k){echo"<tr".odd()."><th>".h($k["field"]),"<td title='".h($k["collation"])."'>".h($k["full_type"]).($k["null"]?" <i>NULL</i>":"").($k["auto_increment"]?" <i>".'Auto Increment'."</i>":""),(isset($k["default"])?" [<b>".h($k["default"])."</b>]":""),(support("comment")?"<td>".nbsp($k["comment"]):""),"\n";}echo"</table>\n";if(!is_view($T)){echo"<h3>".'Indexes'."</h3>\n";$v=indexes($a);if($v){echo"<table cellspacing='0'>\n";foreach($v
  4. as$D=>$u){ksort($u["columns"]);$be=array();foreach($u["columns"]as$y=>$X)$be[]="<i>".h($X)."</i>".($u["lengths"][$y]?"(".$u["lengths"][$y].")":"");echo"<tr title='".h($D)."'><th>$u[type]<td>".implode(", ",$be)."\n";}echo"</table>\n";}echo'<p><a href="'.h(ME).'indexes='.urlencode($a).'">'.'Alter indexes'."</a>\n";if(fk_support($T)){echo"<h3>".'Foreign keys'."</h3>\n";$n=foreign_keys($a);if($n){echo"<table cellspacing='0'>\n","<thead><tr><th>".'Source'."<td>".'Target'."<td>".'ON DELETE'."<td>".'ON UPDATE'.($x!="sqlite"?"<td>&nbsp;":"")."</thead>\n";foreach($n
  5. ';}elseif(isset($_GET["create"])){$a=$_GET["create"];$Md=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$ne=referencable_primary($a);$n=array();foreach($ne
  6. as$Xe=>$k)$n[str_replace("`","``",$Xe)."`".str_replace("`","``",$k["field"])]=$Xe;$Ed=array();$Fd=array();if($a!=""){$Ed=fields($a);$Fd=table_status($a);}if($_POST&&!$_POST["fields"])$_POST["fields"]=array();if($_POST&&!$j&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"])query_redirect("DROP TABLE ".table($a),substr(ME,0,-1),'Table has been dropped.');else{$l=array();$Zb=array();ksort($_POST["fields"]);$Dd=reset($Ed);$oa="FIRST";foreach($_POST["fields"]as$y=>$k){$m=$n[$k["type"]];$wf=($m!==null?$ne[$m]:$k);if($k["field"]!=""){if(!$k["has_default"])$k["default"]=null;$jb=eregi_replace(" *on update CURRENT_TIMESTAMP","",$k["default"]);if($jb!=$k["default"]){$k["on_update"]="CURRENT_TIMESTAMP";$k["default"]=$jb;}if($y==$_POST["auto_increment_col"])$k["auto_increment"]=true;$ge=process_field($k,$wf);if($ge!=process_field($Dd,$Dd))$l[]=array($k["orig"],$ge,$oa);if($m!==null)$Zb[idf_escape($k["field"])]=($a!=""?"ADD":" ")." FOREIGN KEY (".idf_escape($k["field"]).") REFERENCES ".table($n[$k["type"]])." (".idf_escape($wf["field"]).")".(ereg("^($sd)\$",$k["on_delete"])?" ON DELETE $k[on_delete]":"");$oa="AFTER ".idf_escape($k["field"]);}elseif($k["orig"]!="")$l[]=array($k["orig"]);if($k["orig"]!="")$Dd=next($Ed);}$Od="";if(in_array($_POST["partition_by"],$Md)){$Pd=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$y=>$X){$Y=$_POST["partition_values"][$y];$Pd[]="\nPARTITION ".idf_escape($X)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$Od.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($Pd?" (".implode(",",$Pd)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif($a!=""&&support("partitioning"))$Od.="\nREMOVE PARTITIONING";$Yc='Table has been altered.';if($a==""){cookie("adminer_engine",$_POST["Engine"]);$Yc='Table has been created.';}$D=trim($_POST["name"]);queries_redirect(ME."table=".urlencode($D),$Yc,alter_table($a,$D,$l,$Zb,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$Fd["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$Fd["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$Od));}}page_header(($a!=""?'Alter table':'Create table'),$j,array("table"=>$a),$a);$K=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($yf["int"])?"int":(isset($yf["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$K=$_POST;if($K["auto_increment_col"])$K["fields"][$K["auto_increment_col"]]["auto_increment"]=true;process_fields($K["fields"]);}elseif($a!=""){$K=$Fd;$K["name"]=$a;$K["fields"]=array();if(!$_GET["auto_increment"])$K["Auto_increment"]="";foreach($Ed
  7. ';}echo'</form>
  8. ';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$tc=array("PRIMARY","UNIQUE","INDEX");$T=table_status($a);if(eregi("MyISAM|M?aria",$T["Engine"]))$tc[]="FULLTEXT";$v=indexes($a);if($x=="sqlite"){unset($tc[0]);unset($v[""]);}if($_POST&&!$j&&!$_POST["add"]){$ra=array();foreach($_POST["indexes"]as$u){$D=$u["name"];if(in_array($u["type"],$tc)){$e=array();$Mc=array();$P=array();ksort($u["columns"]);foreach($u["columns"]as$y=>$Na){if($Na!=""){$Lc=$u["lengths"][$y];$P[]=idf_escape($Na).($Lc?"(".(+$Lc).")":"");$e[]=$Na;$Mc[]=($Lc?$Lc:null);}}if($e){$Nb=$v[$D];if($Nb){ksort($Nb["columns"]);ksort($Nb["lengths"]);if($u["type"]==$Nb["type"]&&array_values($Nb["columns"])===$e&&(!$Nb["lengths"]||array_values($Nb["lengths"])===$Mc)){unset($v[$D]);continue;}}$ra[]=array($u["type"],$D,"(".implode(", ",$P).")");}}}foreach($v
  9. <thead><tr><th>Index Type<th>Column (length)<th>Name</thead>
  10. ';$w=1;foreach($K["indexes"]as$u){echo"<tr><td>".html_select("indexes[$w][type]",array(-1=>"")+$tc,$u["type"],($w==count($K["indexes"])?"indexesAddRow(this);":1))."<td>";ksort($u["columns"]);$s=1;foreach($u["columns"]as$y=>$Na){echo"<span>".html_select("indexes[$w][columns][$s]",array(-1=>"")+$l,$Na,($s==count($u["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($x=="sql"?"":$_GET["indexes"]."_")."');"),"<input name='indexes[$w][lengths][$s]' size='2' value='".h($u["lengths"][$y])."'> </span>";$s++;}echo"<td><input name='indexes[$w][name]' value='".h($u["name"])."'>\n";$w++;}echo'</table>
  11. </form>
  12. ';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];if($_POST&&!$j&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"])query_redirect("ALTER TABLE ".table($a)."\nDROP ".($x=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($a),'Foreign key has been dropped.');else{$Ie=array_filter($_POST["source"],'strlen');ksort($Ie);$ef=array();foreach($Ie
  13. as$y=>$X)$ef[$y]=$_POST["target"][$y];query_redirect("ALTER TABLE ".table($a).($_GET["name"]!=""?"\nDROP ".($x=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$Ie)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$ef)).")".(ereg("^($sd)\$",$_POST["on_delete"])?" ON DELETE $_POST[on_delete]":"").(ereg("^($sd)\$",$_POST["on_update"])?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($a),($_GET["name"]!=""?'Foreign key has been altered.':'Foreign key has been created.'));$j='Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.'."<br>$j";}}page_header('Foreign key',$j,array("table"=>$a),$a);$K=array("table"=>$a,"source"=>array(""));if($_POST){$K=$_POST;ksort($K["source"]);if($_POST["add"])$K["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$K["target"]=array();}elseif($_GET["name"]!=""){$n=foreign_keys($a);$K=$n[$_GET["name"]];$K["source"][]="";}$Ie=array_keys(fields($a));$ef=($a===$K["table"]?$Ie:array_keys(fields($K["table"])));$me=array();foreach(table_status()as$D=>$T){if(fk_support($T))$me[]=$D;}echo'
  14. <form action="" method="post">
  15. </form>
  16. ';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$we=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$xe=routine_languages();$sb=false;if($_POST&&!$j&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){$P=array();$l=(array)$_POST["fields"];ksort($l);foreach($l

  1. array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU','',$h->result("SHOW CREATE VIEW ".table($A),1)));}function
  2. collations(){$H=array();foreach(get_rows("SHOW COLLATION")as$I){if($I["Default"])$H[$I["Charset"]][-1]=$I["Collation"];else$H[$I["Charset"]][]=$I["Collation"];}ksort($H);foreach($H
  3. ',(support("comment")?"<td".($db?"":" class='hidden'")."><input name='fields[$q][comment]' value='".h($m["comment"])."' maxlength='255'>":"");}echo"<td>",(support("move_col")?"<input type='image' class='icon' name='add[$q]' src='".h(preg_replace("~\\?.*~","",ME))."?file=plus.gif&amp;version=3.6.1' alt='+' title='".lang(97)."' onclick='return !editingAddRow(this, $xa, 1);'>&nbsp;"."<input type='image' class='icon' name='up[$q]' src='".h(preg_replace("~\\?.*~","",ME))."?file=up.gif&amp;version=3.6.1' alt='^' title='".lang(98)."'>&nbsp;"."<input type='image' class='icon' name='down[$q]' src='".h(preg_replace("~\\?.*~","",ME))."?file=down.gif&amp;version=3.6.1' alt='v' title='".lang(99)."'>&nbsp;":""),($je==""||support("drop_col")?"<input type='image' class='icon' name='drop_col[$q]' src='".h(preg_replace("~\\?.*~","",ME))."?file=cross.gif&amp;version=3.6.1' alt='x' title='".lang(100)."' onclick='return !editingRemoveRow(this);'>":""),"\n";}}function
  4. process_fields(&$n){ksort($n);$B=0;if($_POST["up"]){$id=0;foreach($n
  5. as$m){echo"<tr".odd()."><th>".h($m["field"]),"<td title='".h($m["collation"])."'>".h($m["full_type"]).($m["null"]?" <i>NULL</i>":"").($m["auto_increment"]?" <i>".lang(94)."</i>":""),(isset($m["default"])?" [<b>".h($m["default"])."</b>]":""),(support("comment")?"<td>".nbsp($m["comment"]):""),"\n";}echo"</table>\n";if(!is_view($Q)){echo"<h3>".lang(104)."</h3>\n";$u=indexes($a);if($u){echo"<table cellspacing='0'>\n";foreach($u
  6. as$A=>$t){ksort($t["columns"]);$Je=array();foreach($t["columns"]as$w=>$X)$Je[]="<i>".h($X)."</i>".($t["lengths"][$w]?"(".$t["lengths"][$w].")":"");echo"<tr title='".h($A)."'><th>$t[type]<td>".implode(", ",$Je)."\n";}echo"</table>\n";}echo'<p><a href="'.h(ME).'indexes='.urlencode($a).'">'.lang(105)."</a>\n";if(fk_support($Q)){echo"<h3>".lang(86)."</h3>\n";$tc=foreign_keys($a);if($tc){echo"<table cellspacing='0'>\n","<thead><tr><th>".lang(106)."<td>".lang(107)."<td>".lang(88)."<td>".lang(108).($v!="sqlite"?"<td>&nbsp;":"")."</thead>\n";foreach($tc
  7. ';}elseif(isset($_GET["create"])){$a=$_GET["create"];$ue=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$Ve=referencable_primary($a);$tc=array();foreach($Ve
  8. as$Lf=>$m)$tc[str_replace("`","``",$Lf)."`".str_replace("`","``",$m["field"])]=$Lf;$le=array();$me=array();if($a!=""){$le=fields($a);$me=table_status($a);}if($_POST&&!$_POST["fields"])$_POST["fields"]=array();if($_POST&&!$l&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"])query_redirect("DROP TABLE ".table($a),substr(ME,0,-1),lang(145));else{$n=array();$wa=array();$xg=false;$rc=array();ksort($_POST["fields"]);$ke=reset($le);$ua=" FIRST";foreach($_POST["fields"]as$w=>$m){$o=$tc[$m["type"]];$mg=($o!==null?$Ve[$o]:$m);if($m["field"]!=""){if(!$m["has_default"])$m["default"]=null;$wb=eregi_replace(" *on update CURRENT_TIMESTAMP","",$m["default"]);if($wb!=$m["default"]){$m["on_update"]="CURRENT_TIMESTAMP";$m["default"]=$wb;}if($w==$_POST["auto_increment_col"])$m["auto_increment"]=true;$Oe=process_field($m,$mg);$wa[]=array($m["orig"],$Oe,$ua);if($Oe!=process_field($ke,$ke)){$n[]=array($m["orig"],$Oe,$ua);if($m["orig"]!=""||$ua)$xg=true;}if($o!==null)$rc[idf_escape($m["field"])]=($a!=""&&$v!="sqlite"?"ADD":" ")." FOREIGN KEY (".idf_escape($m["field"]).") REFERENCES ".table($tc[$m["type"]])." (".idf_escape($mg["field"]).")".(ereg("^($Xd)\$",$m["on_delete"])?" ON DELETE $m[on_delete]":"");$ua=" AFTER ".idf_escape($m["field"]);}elseif($m["orig"]!=""){$xg=true;$n[]=array($m["orig"]);}if($m["orig"]!=""){$ke=next($le);if(!$ke)$ua="";}}$we="";if(in_array($_POST["partition_by"],$ue)){$xe=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$w=>$X){$Y=$_POST["partition_values"][$w];$xe[]="\nPARTITION ".idf_escape($X)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$we.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($xe?" (".implode(",",$xe)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif(support("partitioning")&&ereg("partitioned",$me["Create_options"]))$we.="\nREMOVE PARTITIONING";$Bd=lang(146);if($a==""){cookie("adminer_engine",$_POST["Engine"]);$Bd=lang(147);}$A=trim($_POST["name"]);queries_redirect(ME."table=".urlencode($A),$Bd,alter_table($a,$A,($v=="sqlite"&&($xg||$rc)?$wa:$n),$rc,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$me["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$me["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$we));}}page_header(($a!=""?lang(30):lang(148)),$l,array("table"=>$a),$a);$I=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($U["int"])?"int":(isset($U["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$I=$_POST;if($I["auto_increment_col"])$I["fields"][$I["auto_increment_col"]]["auto_increment"]=true;process_fields($I["fields"]);}elseif($a!=""){$I=$me;$I["name"]=$a;$I["fields"]=array();if(!$_GET["auto_increment"])$I["Auto_increment"]="";foreach($le
  9. ';}echo'</form>
  10. ';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Nc=array("PRIMARY","UNIQUE","INDEX");$Q=table_status($a);if(eregi("MyISAM|M?aria",$Q["Engine"]))$Nc[]="FULLTEXT";$u=indexes($a);if($v=="sqlite"){unset($Nc[0]);unset($u[""]);}if($_POST&&!$l&&!$_POST["add"]){$c=array();foreach($_POST["indexes"]as$t){$A=$t["name"];if(in_array($t["type"],$Nc)){$f=array();$od=array();$M=array();ksort($t["columns"]);foreach($t["columns"]as$w=>$e){if($e!=""){$x=$t["lengths"][$w];$M[]=idf_escape($e).($x?"(".(+$x).")":"");$f[]=$e;$od[]=($x?$x:null);}}if($f){$ec=$u[$A];if($ec){ksort($ec["columns"]);ksort($ec["lengths"]);if($t["type"]==$ec["type"]&&array_values($ec["columns"])===$f&&(!$ec["lengths"]||array_values($ec["lengths"])===$od)){unset($u[$A]);continue;}}$c[]=array($t["type"],$A,"(".implode(", ",$M).")");}}}foreach($u
  11. <thead><tr><th>',lang(157),'<th>',lang(158),'<th>',lang(159),'</thead>
  12. ';$Zc=1;foreach($I["indexes"]as$t){echo"<tr><td>".html_select("indexes[$Zc][type]",array(-1=>"")+$Nc,$t["type"],($Zc==count($I["indexes"])?"indexesAddRow(this);":1))."<td>";ksort($t["columns"]);$q=1;foreach($t["columns"]as$w=>$e){echo"<span>".html_select("indexes[$Zc][columns][$q]",array(-1=>"")+$n,$e,($q==count($t["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($v=="sql"?"":$_GET["indexes"]."_")."');"),"<input name='indexes[$Zc][lengths][$q]' size='2' value='".h($t["lengths"][$w])."'> </span>";$q++;}echo"<td><input name='indexes[$Zc][name]' value='".h($t["name"])."'>\n";$Zc++;}echo'</table>
  13. </form>
  14. ';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];if($_POST&&!$l&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"])query_redirect("ALTER TABLE ".table($a)."\nDROP ".($v=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($a),lang(170));else{$xf=array_filter($_POST["source"],'strlen');ksort($xf);$Sf=array();foreach($xf
  15. as$w=>$X)$Sf[$w]=$_POST["target"][$w];query_redirect("ALTER TABLE ".table($a).($_GET["name"]!=""?"\nDROP ".($v=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$xf)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$Sf)).")".(ereg("^($Xd)\$",$_POST["on_delete"])?" ON DELETE $_POST[on_delete]":"").(ereg("^($Xd)\$",$_POST["on_update"])?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($a),($_GET["name"]!=""?lang(171):lang(172)));$l=lang(173)."<br>$l";}}page_header(lang(174),$l,array("table"=>$a),$a);$I=array("table"=>$a,"source"=>array(""));if($_POST){$I=$_POST;ksort($I["source"]);if($_POST["add"])$I["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$I["target"]=array();}elseif($_GET["name"]!=""){$tc=foreign_keys($a);$I=$tc[$_GET["name"]];$I["source"][]="";}$xf=array_keys(fields($a));$Sf=($a===$I["table"]?$xf:array_keys(fields($I["table"])));$Ue=array();foreach(table_status()as$A=>$Q){if(fk_support($Q))$Ue[]=$A;}echo'
  16. <form action="" method="post">

  1. array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU','',$h->result("SHOW CREATE VIEW ".table($A),1)));}function
  2. collations(){$H=array();foreach(get_rows("SHOW COLLATION")as$I){if($I["Default"])$H[$I["Charset"]][-1]=$I["Collation"];else$H[$I["Charset"]][]=$I["Collation"];}ksort($H);foreach($H
  3. as$m){echo"<tr".odd()."><th>".h($m["field"]),"<td title='".h($m["collation"])."'>".h($m["full_type"]).($m["null"]?" <i>NULL</i>":"").($m["auto_increment"]?" <i>".lang(94)."</i>":""),(isset($m["default"])?" [<b>".h($m["default"])."</b>]":""),(support("comment")?"<td>".nbsp($m["comment"]):""),"\n";}echo"</table>\n";if(!is_view($P)){echo"<h3>".lang(104)."</h3>\n";$u=indexes($a);if($u){echo"<table cellspacing='0'>\n";foreach($u
  4. as$A=>$t){ksort($t["columns"]);$Ie=array();foreach($t["columns"]as$w=>$W)$Ie[]="<i>".h($W)."</i>".($t["lengths"][$w]?"(".$t["lengths"][$w].")":"");echo"<tr title='".h($A)."'><th>$t[type]<td>".implode(", ",$Ie)."\n";}echo"</table>\n";}echo'<p><a href="'.h(ME).'indexes='.urlencode($a).'">'.lang(105)."</a>\n";if(fk_support($P)){echo"<h3>".lang(86)."</h3>\n";$sc=foreign_keys($a);if($sc){echo"<table cellspacing='0'>\n","<thead><tr><th>".lang(106)."<td>".lang(107)."<td>".lang(88)."<td>".lang(108).($v!="sqlite"?"<td>&nbsp;":"")."</thead>\n";foreach($sc
  5. ';}elseif(isset($_GET["create"])){$a=$_GET["create"];$te=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$Ue=referencable_primary($a);$sc=array();foreach($Ue
  6. as$Lf=>$m)$sc[str_replace("`","``",$Lf)."`".str_replace("`","``",$m["field"])]=$Lf;$ke=array();$le=array();if($a!=""){$ke=fields($a);$le=table_status($a);}if($_POST&&!$_POST["fields"])$_POST["fields"]=array();if($_POST&&!$l&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"])query_redirect("DROP TABLE ".table($a),substr(ME,0,-1),lang(146));else{$n=array();$wa=array();$xg=false;$qc=array();ksort($_POST["fields"]);$je=reset($ke);$ua=" FIRST";foreach($_POST["fields"]as$w=>$m){$o=$sc[$m["type"]];$mg=($o!==null?$Ue[$o]:$m);if($m["field"]!=""){if(!$m["has_default"])$m["default"]=null;$wb=eregi_replace(" *on update CURRENT_TIMESTAMP","",$m["default"]);if($wb!=$m["default"]){$m["on_update"]="CURRENT_TIMESTAMP";$m["default"]=$wb;}if($w==$_POST["auto_increment_col"])$m["auto_increment"]=true;$Ne=process_field($m,$mg);$wa[]=array($m["orig"],$Ne,$ua);if($Ne!=process_field($je,$je)){$n[]=array($m["orig"],$Ne,$ua);if($m["orig"]!=""||$ua)$xg=true;}if($o!==null)$qc[idf_escape($m["field"])]=($a!=""&&$v!="sqlite"?"ADD":" ")." FOREIGN KEY (".idf_escape($m["field"]).") REFERENCES ".table($sc[$m["type"]])." (".idf_escape($mg["field"]).")".(ereg("^($Wd)\$",$m["on_delete"])?" ON DELETE $m[on_delete]":"");$ua=" AFTER ".idf_escape($m["field"]);}elseif($m["orig"]!=""){$xg=true;$n[]=array($m["orig"]);}if($m["orig"]!=""){$je=next($ke);if(!$je)$ua="";}}$ve="";if(in_array($_POST["partition_by"],$te)){$we=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$w=>$W){$X=$_POST["partition_values"][$w];$we[]="\nPARTITION ".idf_escape($W)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($X!=""?" ($X)":" MAXVALUE");}}$ve.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($we?" (".implode(",",$we)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif(support("partitioning")&&ereg("partitioned",$le["Create_options"]))$ve.="\nREMOVE PARTITIONING";$Ad=lang(147);if($a==""){cookie("adminer_engine",$_POST["Engine"]);$Ad=lang(148);}$A=trim($_POST["name"]);queries_redirect(ME."table=".urlencode($A),$Ad,alter_table($a,$A,($v=="sqlite"&&($xg||$qc)?$wa:$n),$qc,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$le["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$le["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$ve));}}page_header(($a!=""?lang(30):lang(149)),$l,array("table"=>$a),$a);$I=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($T["int"])?"int":(isset($T["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$I=$_POST;if($I["auto_increment_col"])$I["fields"][$I["auto_increment_col"]]["auto_increment"]=true;process_fields($I["fields"]);}elseif($a!=""){$I=$le;$I["name"]=$a;$I["fields"]=array();if(!$_GET["auto_increment"])$I["Auto_increment"]="";foreach($ke
  7. ';}echo'</form>
  8. ';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Mc=array("PRIMARY","UNIQUE","INDEX");$P=table_status($a);if(eregi("MyISAM|M?aria",$P["Engine"]))$Mc[]="FULLTEXT";$u=indexes($a);if($v=="sqlite"){unset($Mc[0]);unset($u[""]);}if($_POST&&!$l&&!$_POST["add"]){$c=array();foreach($_POST["indexes"]as$t){$A=$t["name"];if(in_array($t["type"],$Mc)){$f=array();$nd=array();$M=array();ksort($t["columns"]);foreach($t["columns"]as$w=>$e){if($e!=""){$x=$t["lengths"][$w];$M[]=idf_escape($e).($x?"(".(+$x).")":"");$f[]=$e;$nd[]=($x?$x:null);}}if($f){$dc=$u[$A];if($dc){ksort($dc["columns"]);ksort($dc["lengths"]);if($t["type"]==$dc["type"]&&array_values($dc["columns"])===$f&&(!$dc["lengths"]||array_values($dc["lengths"])===$nd)){unset($u[$A]);continue;}}$c[]=array($t["type"],$A,"(".implode(", ",$M).")");}}}foreach($u
  9. <thead><tr><th>',lang(158),'<th>',lang(159),'<th>',lang(160),'</thead>
  10. ';$Yc=1;foreach($I["indexes"]as$t){echo"<tr><td>".html_select("indexes[$Yc][type]",array(-1=>"")+$Mc,$t["type"],($Yc==count($I["indexes"])?"indexesAddRow(this);":1))."<td>";ksort($t["columns"]);$q=1;foreach($t["columns"]as$w=>$e){echo"<span>".html_select("indexes[$Yc][columns][$q]",array(-1=>"")+$n,$e,($q==count($t["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($v=="sql"?"":$_GET["indexes"]."_")."');"),"<input type='number' name='indexes[$Yc][lengths][$q]' class='size' value='".h($t["lengths"][$w])."'> </span>";$q++;}echo"<td><input name='indexes[$Yc][name]' value='".h($t["name"])."'>\n";$Yc++;}echo'</table>
  11. </form>
  12. ';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];if($_POST&&!$l&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"])query_redirect("ALTER TABLE ".table($a)."\nDROP ".($v=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($a),lang(171));else{$wf=array_filter($_POST["source"],'strlen');ksort($wf);$Sf=array();foreach($wf
  13. as$w=>$W)$Sf[$w]=$_POST["target"][$w];query_redirect("ALTER TABLE ".table($a).($_GET["name"]!=""?"\nDROP ".($v=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$wf)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$Sf)).")".(ereg("^($Wd)\$",$_POST["on_delete"])?" ON DELETE $_POST[on_delete]":"").(ereg("^($Wd)\$",$_POST["on_update"])?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($a),($_GET["name"]!=""?lang(172):lang(173)));$l=lang(174)."<br>$l";}}page_header(lang(175),$l,array("table"=>$a),$a);$I=array("table"=>$a,"source"=>array(""));if($_POST){$I=$_POST;ksort($I["source"]);if($_POST["add"])$I["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$I["target"]=array();}elseif($_GET["name"]!=""){$sc=foreign_keys($a);$I=$sc[$_GET["name"]];$I["source"][]="";}$wf=array_keys(fields($a));$Sf=($a===$I["table"]?$wf:array_keys(fields($I["table"])));$Te=array();foreach(table_status()as$A=>$P){if(fk_support($P))$Te[]=$A;}echo'
  14. <form action="" method="post">
  15. </form>
  16. ';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$gf=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$hf=routine_languages();$Gb=false;if($_POST&&!$l&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){$M=array();$n=(array)$_POST["fields"];ksort($n);foreach($n

  1. array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU','',$g->result("SHOW CREATE VIEW ".table($_),1)));}function
  2. collations(){$F=array();foreach(get_rows("SHOW COLLATION")as$G){if($G["Default"])$F[$G["Charset"]][-1]=$G["Collation"];else$F[$G["Charset"]][]=$G["Collation"];}ksort($F);foreach($F
  3. ',(support("comment")?"<td".($Xa?"":" class='hidden'")."><input name='fields[$p][comment]' value='".h($l["comment"])."' maxlength='255'>":"");}echo"<td>",(support("move_col")?"<input type='image' name='add[$p]' src='".h(preg_replace("~\\?.*~","",ME))."?file=plus.gif&amp;version=3.4.0' alt='+' title='".lang(97)."' onclick='return !editingAddRow(this, $wa, 1);'>&nbsp;"."<input type='image' name='up[$p]' src='".h(preg_replace("~\\?.*~","",ME))."?file=up.gif&amp;version=3.4.0' alt='^' title='".lang(98)."'>&nbsp;"."<input type='image' name='down[$p]' src='".h(preg_replace("~\\?.*~","",ME))."?file=down.gif&amp;version=3.4.0' alt='v' title='".lang(99)."'>&nbsp;":""),($Td==""||support("drop_col")?"<input type='image' name='drop_col[$p]' src='".h(preg_replace("~\\?.*~","",ME))."?file=cross.gif&amp;version=3.4.0' alt='x' title='".lang(100)."' onclick='return !editingRemoveRow(this);'>":""),"\n";}}function
  4. process_fields(&$m){ksort($m);$A=0;if($_POST["up"]){$Tc=0;foreach($m
  5. as$l){echo"<tr".odd()."><th>".h($l["field"]),"<td title='".h($l["collation"])."'>".h($l["full_type"]).($l["null"]?" <i>NULL</i>":"").($l["auto_increment"]?" <i>".lang(94)."</i>":""),(isset($l["default"])?" [<b>".h($l["default"])."</b>]":""),(support("comment")?"<td>".nbsp($l["comment"]):""),"\n";}echo"</table>\n";if(!is_view($O)){echo"<h3>".lang(104)."</h3>\n";$t=indexes($a);if($t){echo"<table cellspacing='0'>\n";foreach($t
  6. as$_=>$s){ksort($s["columns"]);$te=array();foreach($s["columns"]as$v=>$W)$te[]="<i>".h($W)."</i>".($s["lengths"][$v]?"(".$s["lengths"][$v].")":"");echo"<tr title='".h($_)."'><th>$s[type]<td>".implode(", ",$te)."\n";}echo"</table>\n";}echo'<p><a href="'.h(ME).'indexes='.urlencode($a).'">'.lang(105)."</a>\n";if(fk_support($O)){echo"<h3>".lang(86)."</h3>\n";$jc=foreign_keys($a);if($jc){echo"<table cellspacing='0'>\n","<thead><tr><th>".lang(106)."<td>".lang(107)."<td>".lang(88)."<td>".lang(108).($u!="sqlite"?"<td>&nbsp;":"")."</thead>\n";foreach($jc
  7. ';}elseif(isset($_GET["create"])){$a=$_GET["create"];$ee=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$Ee=referencable_primary($a);$jc=array();foreach($Ee
  8. as$sf=>$l)$jc[str_replace("`","``",$sf)."`".str_replace("`","``",$l["field"])]=$sf;$Vd=array();$Wd=array();if($a!=""){$Vd=fields($a);$Wd=table_status($a);}if($_POST&&!$_POST["fields"])$_POST["fields"]=array();if($_POST&&!$k&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"])query_redirect("DROP TABLE ".table($a),substr(ME,0,-1),lang(145));else{$m=array();$hc=array();ksort($_POST["fields"]);$Ud=reset($Vd);$ua="FIRST";foreach($_POST["fields"]as$v=>$l){$n=$jc[$l["type"]];$Pf=($n!==null?$Ee[$n]:$l);if($l["field"]!=""){if(!$l["has_default"])$l["default"]=null;$pb=eregi_replace(" *on update CURRENT_TIMESTAMP","",$l["default"]);if($pb!=$l["default"]){$l["on_update"]="CURRENT_TIMESTAMP";$l["default"]=$pb;}if($v==$_POST["auto_increment_col"])$l["auto_increment"]=true;$ye=process_field($l,$Pf);if($ye!=process_field($Ud,$Ud))$m[]=array($l["orig"],$ye,$ua);if($n!==null)$hc[idf_escape($l["field"])]=($a!=""?"ADD":" ")." FOREIGN KEY (".idf_escape($l["field"]).") REFERENCES ".table($jc[$l["type"]])." (".idf_escape($Pf["field"]).")".(ereg("^($Hd)\$",$l["on_delete"])?" ON DELETE $l[on_delete]":"");$ua="AFTER ".idf_escape($l["field"]);}elseif($l["orig"]!="")$m[]=array($l["orig"]);if($l["orig"]!="")$Ud=next($Vd);}$ge="";if(in_array($_POST["partition_by"],$ee)){$he=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$v=>$W){$X=$_POST["partition_values"][$v];$he[]="\nPARTITION ".idf_escape($W)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($X!=""?" ($X)":" MAXVALUE");}}$ge.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($he?" (".implode(",",$he)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif($a!=""&&support("partitioning"))$ge.="\nREMOVE PARTITIONING";$nd=lang(146);if($a==""){cookie("adminer_engine",$_POST["Engine"]);$nd=lang(147);}$_=trim($_POST["name"]);queries_redirect(ME."table=".urlencode($_),$nd,alter_table($a,$_,$m,$hc,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$Wd["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$Wd["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$ge));}}page_header(($a!=""?lang(30):lang(148)),$k,array("table"=>$a),$a);$G=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($T["int"])?"int":(isset($T["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$G=$_POST;if($G["auto_increment_col"])$G["fields"][$G["auto_increment_col"]]["auto_increment"]=true;process_fields($G["fields"]);}elseif($a!=""){$G=$Wd;$G["name"]=$a;$G["fields"]=array();if(!$_GET["auto_increment"])$G["Auto_increment"]="";foreach($Vd
  9. ';}echo'</form>
  10. ';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Dc=array("PRIMARY","UNIQUE","INDEX");$O=table_status($a);if(eregi("MyISAM|M?aria",$O["Engine"]))$Dc[]="FULLTEXT";$t=indexes($a);if($u=="sqlite"){unset($Dc[0]);unset($t[""]);}if($_POST&&!$k&&!$_POST["add"]){$c=array();foreach($_POST["indexes"]as$s){$_=$s["name"];if(in_array($s["type"],$Dc)){$f=array();$Zc=array();$K=array();ksort($s["columns"]);foreach($s["columns"]as$v=>$e){if($e!=""){$w=$s["lengths"][$v];$K[]=idf_escape($e).($w?"(".(+$w).")":"");$f[]=$e;$Zc[]=($w?$w:null);}}if($f){$Ub=$t[$_];if($Ub){ksort($Ub["columns"]);ksort($Ub["lengths"]);if($s["type"]==$Ub["type"]&&array_values($Ub["columns"])===$f&&(!$Ub["lengths"]||array_values($Ub["lengths"])===$Zc)){unset($t[$_]);continue;}}$c[]=array($s["type"],$_,"(".implode(", ",$K).")");}}}foreach($t
  11. </form>
  12. ';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];if($_POST&&!$k&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"])query_redirect("ALTER TABLE ".table($a)."\nDROP ".($u=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($a),lang(170));else{$df=array_filter($_POST["source"],'strlen');ksort($df);$zf=array();foreach($df
  13. as$v=>$W)$zf[$v]=$_POST["target"][$v];query_redirect("ALTER TABLE ".table($a).($_GET["name"]!=""?"\nDROP ".($u=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$df)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$zf)).")".(ereg("^($Hd)\$",$_POST["on_delete"])?" ON DELETE $_POST[on_delete]":"").(ereg("^($Hd)\$",$_POST["on_update"])?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($a),($_GET["name"]!=""?lang(171):lang(172)));$k=lang(173)."<br>$k";}}page_header(lang(174),$k,array("table"=>$a),$a);$G=array("table"=>$a,"source"=>array(""));if($_POST){$G=$_POST;ksort($G["source"]);if($_POST["add"])$G["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$G["target"]=array();}elseif($_GET["name"]!=""){$jc=foreign_keys($a);$G=$jc[$_GET["name"]];$G["source"][]="";}$df=array_keys(fields($a));$zf=($a===$G["table"]?$df:array_keys(fields($G["table"])));$De=array();foreach(table_status()as$_=>$O){if(fk_support($O))$De[]=$_;}echo'
  14. <form action="" method="post">
  15. </form>
  16. ';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$Ne=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$Oe=routine_languages();$yb=false;if($_POST&&!$k&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){$K=array();$m=(array)$_POST["fields"];ksort($m);foreach($m










Back to Top