_db = $db; $this->_table = $table; $this->_searchType = $searchType; $this->_columnNames = array(); $this->_columnNullFlags = array(); $this->_columnTypes = array(); $this->_columnCollations = array(); $this->_geomColumnFlag = false; $this->_foreigners = array(); // Loads table's information $this->_loadTableInfo(); } /** * Returns Column names array * * @return array column names */ public function getColumnNames() { return $this->_columnNames; } /** * Gets all the columns of a table along with their types, collations * and whether null or not. * * @return void */ private function _loadTableInfo() { // Gets the list and number of columns $columns = $GLOBALS['dbi']->getColumns( $this->_db, $this->_table, null, true ); // Get details about the geometry functions $geom_types = PMA_Util::getGISDatatypes(); foreach ($columns as $row) { // set column name $this->_columnNames[] = $row['Field']; $type = $row['Type']; // check whether table contains geometric columns if (in_array($type, $geom_types)) { $this->_geomColumnFlag = true; } // reformat mysql query output if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0 ) { $type = str_replace(',', ', ', $type); } else { // strip the "BINARY" attribute, except if we find "BINARY(" because // this would be a BINARY or VARBINARY column type if (! preg_match('@BINARY[\(]@i', $type)) { $type = preg_replace('@BINARY@i', '', $type); } $type = preg_replace('@ZEROFILL@i', '', $type); $type = preg_replace('@UNSIGNED@i', '', $type); $type = /*overload*/mb_strtolower($type); } if (empty($type)) { $type = ' '; } $this->_columnTypes[] = $type; $this->_columnNullFlags[] = $row['Null']; $this->_columnCollations[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : ''; } // end for // Retrieve foreign keys $this->_foreigners = PMA_getForeigners($this->_db, $this->_table); } /** * Sets the table header for displaying a table in query-by-example format. * * @return string HTML content, the tags and content for table header */ private function _getTableHeader() { // Display the Function column only if there is at least one geometry column $func = ''; if ($this->_geomColumnFlag) { $func = '