/** * Function to get table creation sql query * * @param string $db database name * @param string $table table name * * @return string */ function PMA_getTableCreationQuery($db, $table) { // get column addition statements $sql_statement = PMA_getColumnCreationStatements(true); // Builds the 'create table' statement $sql_query = 'CREATE TABLE ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote(trim($table)) . ' (' . $sql_statement . ')'; // Adds table type, character set, comments and partition definition if (!empty($_REQUEST['tbl_storage_engine']) && $_REQUEST['tbl_storage_engine'] != 'Default') { $sql_query .= ' ENGINE = ' . $_REQUEST['tbl_storage_engine']; } if (!empty($_REQUEST['tbl_collation'])) { $sql_query .= PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']); } if (!empty($_REQUEST['connection']) && !empty($_REQUEST['tbl_storage_engine']) && $_REQUEST['tbl_storage_engine'] == 'FEDERATED') { $sql_query .= " CONNECTION = '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['connection']) . "'"; } if (!empty($_REQUEST['comment'])) { $sql_query .= ' COMMENT = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['comment']) . '\''; } $sql_query .= PMA_getPartitionsDefinition(); $sql_query .= ';'; return $sql_query; }
/** * Update the table's partitioning based on $_REQUEST * * @return void */ protected function updatePartitioning() { include_once 'libraries/create_addfield.lib.php'; $sql_query = "ALTER TABLE " . Util::backquote($this->table) . " " . PMA_getPartitionsDefinition(); // Execute alter query $result = $this->dbi->tryQuery($sql_query); if ($result !== false) { $message = Message::success(__('Table %1$s has been altered successfully.')); $message->addParam($this->table); $this->response->addHTML(Util::getMessage($message, $sql_query, 'success')); } else { $this->response->setRequestStatus(false); $this->response->addJSON('message', Message::rawError(__('Query error') . ':<br />' . $this->dbi->getError())); } }