CMS  Version 3.9
table_information.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("developer_tools");
3 
4 $menu_item = "Table Information";
5 
6 $tables = Query::create(TableInformation, "WHERE TABLE_SCHEMA=DATABASE() AND TABLE_TYPE='BASE TABLE' ORDER BY TABLE_TYPE, TABLE_NAME")->execute();
7 
9 
10 $form = new AutoForm($charset);
11 
12 $characterSets = Query::create(CharacterSet, "ORDER BY CHARACTER_SET_NAME")->execute();
13 $options = array(""=>"");
14 
15 foreach($characterSets as $set)
16 {
17  $options[$set->CHARACTER_SET_NAME] = $set->format("{CHARACTER_SET_NAME} - {DESCRIPTION}");
18 }
19 
20 $form->dropdown("character_set", "Convert to Character Set", $options);
21 $form->required("character_set");
22 $form->submitLabel = "Update Character Sets";
23 
24 $tableSelect = new TableSelectFieldRenderer($form, "tables", "Tables",
25  function($table)
26  {
27  $table->column("Table Name", "{TABLE_NAME}", true)
28  ->column("Collation", "{TABLE_COLLATION}", true)
29  ->column("# Rows", "{TABLE_ROWS}", true, "text-align: right");
30 
31  $table->sortable = true;
32  $table->filter = true;
33  $table->pageSize = 20;
34  $table->emptyMessage = "Schema is empty";
35  $table->excelFile = "table_list.xls";
36 
37  $table->showSelectAll = true;
38  $table->commandMenu();
39  },
40 
41  function($field)
42  {
43  if (!$field) $field = $this->field;
45  $charset = $_POST["character_set"];
46 
47  foreach($tables as $table)
48  {
49  trace("Updating character set for $table to $charset", 3);
51  }
52 
53  return true;
54  },
55 
56  "multi", $tables
57 );
58 
59 if ($method == "POST")
60 {
61  if ($form->save())
62  {
63  Fakoli::notify("Changes Saved");
64  $tableSelect->data = Query::create(TableInformation, "WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_TYPE, TABLE_NAME")->execute();
65 
66  }
67  else
68  {
69  Fakoli::notify($form->msg);
70  }
71 }
72 
73 $script .= $form->writeScript();
74 $form->drawForm();
$_POST["owner_id"]
Definition: blog_form.inc:54
$characterSets
$menu_item
$tableSelect
if($method=="POST") $script
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static notify($message, $blocking=false, $button="OK", $onClick="null")
Utility method to display a notification message to the user when the page has finished loading.
Definition: core.inc:1198
static updateCharacterSet($table, $charset)
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573