DboSource::readTableParameters PHP Method

readTableParameters() public method

Read additional table parameters
public readTableParameters ( string $name ) : array
$name string The table name to read.
return array
    public function readTableParameters($name)
    {
        $parameters = array();
        if (method_exists($this, 'listDetailedSources')) {
            $currentTableDetails = $this->listDetailedSources($name);
            foreach ($this->tableParameters as $paramName => $parameter) {
                if (!empty($parameter['column']) && !empty($currentTableDetails[$parameter['column']])) {
                    $parameters[$paramName] = $currentTableDetails[$parameter['column']];
                }
            }
        }
        return $parameters;
    }

Usage Example

コード例 #1
0
 /**
  * testReadTableParameters method
  *
  * @access public
  * @return void
  */
 function testReadTableParameters()
 {
     $this->Dbo->cacheSources = $this->Dbo->testing = false;
     $tableName = 'tinyint_' . uniqid();
     $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;');
     $result = $this->Dbo->readTableParameters($tableName);
     $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
     $expected = array('charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'engine' => 'InnoDB');
     $this->assertEqual($result, $expected);
     $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
     $result = $this->Dbo->readTableParameters($tableName);
     $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
     $expected = array('charset' => 'cp1250', 'collate' => 'cp1250_general_ci', 'engine' => 'MyISAM');
     $this->assertEqual($result, $expected);
 }
All Usage Examples Of DboSource::readTableParameters
DboSource