/** * Test for PMA_SQP_isKeyWord * * @return void */ public function testPMA_SQP_isKeyWord() { PMA_SQP_resetError(); $this->assertTrue(PMA_SQP_isKeyWord("ACCESSIBLE")); $this->assertTrue(PMA_SQP_isKeyWord("accessible")); $this->assertTrue(PMA_SQP_isKeyWord("ASC")); $this->assertFalse(PMA_SQP_isKeyWord("hello")); }
/** * Get all column names which are MySQL reserved words * * @return array * @access public */ public function getReservedColumnNames() { $columns = $this->getColumns($backquoted = false); $return = array(); foreach ($columns as $column) { $temp = explode('.', $column); $column_name = $temp[2]; if (PMA_SQP_isKeyWord($column_name)) { $return[] = $column_name; } } return $return; }
exit; } /** * handle MySQL reserved words columns check */ if (isset($_REQUEST['reserved_word_check'])) { $response = PMA_Response::getInstance(); if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) { $columns_names = $_REQUEST['field_name']; $reserved_keywords_names = array(); foreach ($columns_names as $column) { if (PMA_SQP_isKeyWord(trim($column))) { $reserved_keywords_names[] = trim($column); } } if (PMA_SQP_isKeyWord(trim($table))) { $reserved_keywords_names[] = trim($table); } if (count($reserved_keywords_names) == 0) { $response->isSuccess(false); } $response->addJSON('message', sprintf(_ngettext('The name \'%s\' is a MySQL reserved keyword.', 'The names \'%s\' are MySQL reserved keywords.', count($reserved_keywords_names)), implode(',', $reserved_keywords_names))); } else { $response->isSuccess(false); } exit; } /** * A click on Change has been made for one column */ if (isset($_REQUEST['change_column'])) {