Simplify getting table create options

- use saner method name (getCreateOptions)
- fix error case

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2017-03-06 09:56:20 +01:00
parent a51ac4ef8b
commit 159e748a2b
5 changed files with 15 additions and 18 deletions

View File

@ -392,7 +392,7 @@ class Table
* @param Current table properties.
* @return Return auto increment info if it is set for the selected table or return blank.
*/
public function getAutoIncrementInfo() {
public function getAutoIncrement() {
$table_auto_increment = $this->getStatusInfo('AUTO_INCREMENT', false, true);
return isset($table_auto_increment) ? $table_auto_increment : '';
}
@ -402,11 +402,9 @@ class Table
* @param Current table properties.
* @return Return options array info if it is set for the selected table or return blank.
*/
public function createOptionsArray() {
public function getCreateOptions() {
$table_options = $this->getStatusInfo('CREATE_OPTIONS', false, true);
$create_options_tmp = isset($table_options)
? explode(' ', $table_options)
: array();
$create_options_tmp = empty($table_options) ? array() : explode(' ', $table_options);
$create_options = array();
// export create options by its name as variables into global namespace
// f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
@ -422,7 +420,6 @@ class Table
$create_options['pack_keys'] = (! isset($create_options['pack_keys']) || strlen($create_options['pack_keys']) == 0)
? 'DEFAULT'
: $create_options['pack_keys'];
unset($create_options_tmp, $each_create_option);
return $create_options;
}

View File

@ -133,8 +133,8 @@ class TableChartController extends TableController
$tbl_collation = $table_class_object->getCollation();
$table_info_num_rows = $table_class_object->getNumRows();
$row_format = $table_class_object->getRowFormat();
$auto_increment = $table_class_object->getAutoIncrementInfo();
$create_options = $table_class_object->createOptionsArray();
$auto_increment = $table_class_object->getAutoIncrement();
$create_options = $table_class_object->getCreateOptions();
} elseif (strlen($this->db) > 0) {
$url_params['goto'] = Util::getScriptNameForOption(
$this->cfg['DefaultTabDatabase'], 'database'

View File

@ -81,8 +81,8 @@ class TableIndexesController extends TableController
$tbl_collation = $table_class_object->getCollation();
$table_info_num_rows = $table_class_object->getNumRows();
$row_format = $table_class_object->getRowFormat();
$auto_increment = $table_class_object->getAutoIncrementInfo();
$create_options = $table_class_object->createOptionsArray();
$auto_increment = $table_class_object->getAutoIncrement();
$create_options = $table_class_object->getCreateOptions();
$add_fields = 0;
if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
// coming already from form

View File

@ -227,8 +227,8 @@ if ($reread_info) {
$tbl_collation = $pma_table->getCollation();
$table_info_num_rows = $pma_table->getNumRows();
$row_format = $pma_table->getRowFormat();
$auto_increment = $pma_table->getAutoIncrementInfo();
$create_options = $pma_table->createOptionsArray();
$auto_increment = $pma_table->getAutoIncrement();
$create_options = $pma_table->getCreateOptions();
}
unset($reread_info);

View File

@ -1295,11 +1295,11 @@ class TableTest extends PMATestCase
}
/**
* Test for getAutoIncrementInfo
* Test for getAutoIncrement
*
* @return void
*/
public function testGetAutoIncrementInfo(){
public function testGetAutoIncrement(){
$target_table = 'table1';
$target_db = 'pma_test';
$tbl_object = new Table($target_db, $target_table);
@ -1310,7 +1310,7 @@ class TableTest extends PMATestCase
$auto_increment = $dbi->getTable(
$target_db,
$target_table
)->getAutoIncrementInfo();
)->getAutoIncrement();
$this->assertEquals(
$expect,
$auto_increment
@ -1318,11 +1318,11 @@ class TableTest extends PMATestCase
}
/**
* Test for createOptionsArray
* Test for getCreateOptions
*
* @return void
*/
public function testCreateOptionsArray(){
public function testGetCreateOptions(){
$target_table = 'table1';
$target_db = 'pma_test';
$tbl_object = new Table($target_db, $target_table);
@ -1333,7 +1333,7 @@ class TableTest extends PMATestCase
$create_options = $dbi->getTable(
$target_db,
$target_table
)->createOptionsArray();
)->getCreateOptions();
$this->assertEquals(
$expect,
$create_options