本文整理汇总了PHP中SqlParser\Context::isKeyword方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::isKeyword方法的具体用法?PHP Context::isKeyword怎么用?PHP Context::isKeyword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlParser\Context
的用法示例。
在下文中一共展示了Context::isKeyword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsKeyword
public function testIsKeyword()
{
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED, Context::isKeyword('SELECT'));
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED, Context::isKeyword('ALL'));
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED, Context::isKeyword('DISTINCT'));
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED | Token::FLAG_KEYWORD_COMPOSED | Token::FLAG_KEYWORD_KEY, Context::isKeyword('PRIMARY KEY'));
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED | Token::FLAG_KEYWORD_COMPOSED, Context::isKeyword('CHARACTER SET'));
$this->assertEquals(1 | Token::FLAG_KEYWORD_RESERVED, Context::isKeyword('FROM', true));
$this->assertEquals(null, Context::isKeyword('MODIFY', true));
$this->assertEquals(null, Context::isKeyword('foo'));
$this->assertEquals(null, Context::isKeyword('bar baz'));
}
示例2: backquoteCompat
/**
* Adds backquotes on both sides of a database, table or field name.
* in compatibility mode
*
* example:
* <code>
* echo backquoteCompat('owner`s db'); // `owner``s db`
*
* </code>
*
* @param mixed $a_name the database, table or field name to
* "backquote" or array of it
* @param string $compatibility string compatibility mode (used by dump
* functions)
* @param boolean $do_it a flag to bypass this function (used by dump
* functions)
*
* @return mixed the "backquoted" database, table or field name
*
* @access public
*/
public static function backquoteCompat(
$a_name,
$compatibility = 'MSSQL',
$do_it = true
) {
if (is_array($a_name)) {
foreach ($a_name as &$data) {
$data = self::backquoteCompat($data, $compatibility, $do_it);
}
return $a_name;
}
if (! $do_it) {
if (!Context::isKeyword($a_name)) {
return $a_name;
}
}
// @todo add more compatibility cases (ORACLE for example)
switch ($compatibility) {
case 'MSSQL':
$quote = '"';
break;
default:
$quote = "`";
break;
}
// '0' is also empty for php :-(
if (strlen($a_name) > 0 && $a_name !== '*') {
return $quote . $a_name . $quote;
} else {
return $a_name;
}
} // end of the 'backquoteCompat()' function
示例3: parseKeyword
/**
* Parses a keyword.
*
* @return Token
*/
public function parseKeyword()
{
$token = '';
/**
* Value to be returned.
* @var Token $ret
*/
$ret = null;
/**
* The value of `$this->last` where `$token` ends in `$this->str`.
* @var int $iEnd
*/
$iEnd = $this->last;
/**
* Whether last parsed character is a whitespace.
* @var bool $lastSpace
*/
$lastSpace = false;
for ($j = 1; $j < Context::KEYWORD_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
// Composed keywords shouldn't have more than one whitespace between
// keywords.
if (Context::isWhitespace($this->str[$this->last])) {
if ($lastSpace) {
--$j;
// The size of the keyword didn't increase.
continue;
} else {
$lastSpace = true;
}
} else {
$lastSpace = false;
}
$token .= $this->str[$this->last];
if ($this->last + 1 === $this->len || Context::isSeparator($this->str[$this->last + 1])) {
if ($flags = Context::isKeyword($token)) {
$ret = new Token($token, Token::TYPE_KEYWORD, $flags);
$iEnd = $this->last;
// We don't break so we find longest keyword.
// For example, `OR` and `ORDER` have a common prefix `OR`.
// If we stopped at `OR`, the parsing would be invalid.
}
}
}
$this->last = $iEnd;
return $ret;
}
示例4: indexAction
/**
* Index action
*
* @return void
*/
public function indexAction()
{
PMA_PageSettings::showGroup('TableStructure');
/**
* Function implementations for this script
*/
include_once 'libraries/check_user_privileges.lib.php';
include_once 'libraries/index.lib.php';
include_once 'libraries/sql.lib.php';
include_once 'libraries/bookmark.lib.php';
$this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
/**
* Handle column moving
*/
if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
$this->moveColumns();
return;
}
/**
* handle MySQL reserved words columns check
*/
if (isset($_REQUEST['reserved_word_check'])) {
if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
$columns_names = $_REQUEST['field_name'];
$reserved_keywords_names = array();
foreach ($columns_names as $column) {
if (SqlParser\Context::isKeyword(trim($column), true)) {
$reserved_keywords_names[] = trim($column);
}
}
if (SqlParser\Context::isKeyword(trim($this->table), true)) {
$reserved_keywords_names[] = trim($this->table);
}
if (count($reserved_keywords_names) == 0) {
$this->response->isSuccess(false);
}
$this->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 {
$this->response->isSuccess(false);
}
return;
}
/**
* A click on Change has been made for one column
*/
if (isset($_REQUEST['change_column'])) {
$this->displayHtmlForColumnChange(null, 'tbl_structure.php');
return;
}
/**
* handle multiple field commands if required
*
* submit_mult_*_x comes from IE if <input type="img" ...> is used
*/
$submit_mult = $this->getMultipleFieldCommandType();
if (!empty($submit_mult)) {
if (isset($_REQUEST['selected_fld'])) {
if ($submit_mult == 'browse') {
// browsing the table displaying only selected columns
$this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']);
} else {
// handle multiple field commands
// handle confirmation of deleting multiple columns
$action = 'tbl_structure.php';
$GLOBALS['selected'] = $_REQUEST['selected_fld'];
list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action);
//update the existing variables
// todo: refactor mult_submits.inc.php such as
// below globals are not needed anymore
if (isset($what_ret)) {
$GLOBALS['what'] = $what_ret;
global $what;
}
if (isset($query_type_ret)) {
$GLOBALS['query_type'] = $query_type_ret;
global $query_type;
}
if ($is_unset_submit_mult) {
unset($submit_mult);
}
if (isset($mult_btn_ret)) {
$GLOBALS['mult_btn'] = $mult_btn_ret;
global $mult_btn;
}
include 'libraries/mult_submits.inc.php';
/**
* if $submit_mult == 'change', execution will have stopped
* at this point
*/
if (empty($message)) {
$message = PMA_Message::success();
}
$this->response->addHTML(PMA_Util::getMessage($message, $sql_query));
}
} else {
//.........这里部分代码省略.........
示例5: getReservedColumnNames
/**
* Get all column names which are MySQL reserved words
*
* @return array
* @access public
*/
public function getReservedColumnNames()
{
$columns = $this->getColumns(false);
$return = array();
foreach ($columns as $column) {
$temp = explode('.', $column);
$column_name = $temp[2];
if (Context::isKeyword($column_name, true)) {
$return[] = $column_name;
}
}
return $return;
}
示例6: parseKeyword
/**
* Parses a keyword.
*
* @return Token
*/
public function parseKeyword()
{
$token = '';
/**
* Value to be returned.
* @var Token
*/
$ret = null;
/**
* The value of `$this->last` where `$token` ends in `$this->str`.
* @var int
*/
$iEnd = $this->last;
for ($j = 1; $j < Context::KEYWORD_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
$token .= $this->str[$this->last];
if ($this->last + 1 === $this->len || Context::isSeparator($this->str[$this->last + 1])) {
if ($flags = Context::isKeyword($token)) {
$ret = new Token($token, Token::TYPE_KEYWORD, $flags);
$iEnd = $this->last;
// We don't break so we find longest keyword.
// For example, `OR` and `ORDER` have a common prefix `OR`.
// If we stopped at `OR`, the parsing would be invalid.
}
}
}
$this->last = $iEnd;
return $ret;
}
示例7: indexAction
/**
* Index action
*
* @return void
*/
public function indexAction()
{
PageSettings::showGroup('TableStructure');
/**
* Function implementations for this script
*/
include_once 'libraries/check_user_privileges.lib.php';
include_once 'libraries/index.lib.php';
include_once 'libraries/sql.lib.php';
$this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
/**
* Handle column moving
*/
if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
$this->moveColumns();
return;
}
/**
* handle MySQL reserved words columns check
*/
if (isset($_REQUEST['reserved_word_check'])) {
if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
$columns_names = $_REQUEST['field_name'];
$reserved_keywords_names = array();
foreach ($columns_names as $column) {
if (SqlParser\Context::isKeyword(trim($column), true)) {
$reserved_keywords_names[] = trim($column);
}
}
if (SqlParser\Context::isKeyword(trim($this->table), true)) {
$reserved_keywords_names[] = trim($this->table);
}
if (count($reserved_keywords_names) == 0) {
$this->response->setRequestStatus(false);
}
$this->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 {
$this->response->setRequestStatus(false);
}
return;
}
/**
* A click on Change has been made for one column
*/
if (isset($_REQUEST['change_column'])) {
$this->displayHtmlForColumnChange(null, 'tbl_structure.php');
return;
}
/**
* Adding or editing partitioning of the table
*/
if (isset($_REQUEST['edit_partitioning']) && !isset($_REQUEST['save_partitioning'])) {
$this->displayHtmlForPartitionChange();
return;
}
/**
* handle multiple field commands if required
*
* submit_mult_*_x comes from IE if <input type="img" ...> is used
*/
$submit_mult = $this->getMultipleFieldCommandType();
if (!empty($submit_mult)) {
if (isset($_REQUEST['selected_fld'])) {
if ($submit_mult == 'browse') {
// browsing the table displaying only selected columns
$this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']);
} else {
// handle multiple field commands
// handle confirmation of deleting multiple columns
$action = 'tbl_structure.php';
$GLOBALS['selected'] = $_REQUEST['selected_fld'];
list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action);
//update the existing variables
// todo: refactor mult_submits.inc.php such as
// below globals are not needed anymore
if (isset($what_ret)) {
$GLOBALS['what'] = $what_ret;
global $what;
}
if (isset($query_type_ret)) {
$GLOBALS['query_type'] = $query_type_ret;
global $query_type;
}
if ($is_unset_submit_mult) {
unset($submit_mult);
}
if (isset($mult_btn_ret)) {
$GLOBALS['mult_btn'] = $mult_btn_ret;
global $mult_btn;
}
include 'libraries/mult_submits.inc.php';
/**
* if $submit_mult == 'change', execution will have stopped
* at this point
*/
//.........这里部分代码省略.........
示例8: indexAction
//.........这里部分代码省略.........
*/
/* DATABASE WORK */
/* Printable view of a table */
$this->response->addHTML(Template::get('structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query)));
if (empty($db_is_system_schema)) {
$this->response->addHTML(PMA_getHtmlForCreateTable($this->_db));
}
} elseif ($this->_type == 'table') {
// Table structure
PMA_PageSettings::showGroup('TableStructure');
/**
* Function implementations for this script
*/
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/sql.lib.php';
require_once 'libraries/bookmark.lib.php';
$this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
/**
* Handle column moving
*/
if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
$this->moveColumns();
return;
}
/**
* handle MySQL reserved words columns check
*/
if (isset($_REQUEST['reserved_word_check'])) {
if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
$columns_names = $_REQUEST['field_name'];
$reserved_keywords_names = array();
foreach ($columns_names as $column) {
if (SqlParser\Context::isKeyword(trim($column), true)) {
$reserved_keywords_names[] = trim($column);
}
}
if (SqlParser\Context::isKeyword(trim($this->_table), true)) {
$reserved_keywords_names[] = trim($this->_table);
}
if (count($reserved_keywords_names) == 0) {
$this->response->isSuccess(false);
}
$this->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 {
$this->response->isSuccess(false);
}
return;
}
/**
* A click on Change has been made for one column
*/
if (isset($_REQUEST['change_column'])) {
$this->displayHtmlForColumnChange(null, 'tbl_structure.php');
return;
}
/**
* handle multiple field commands if required
*
* submit_mult_*_x comes from IE if <input type="img" ...> is used
*/
$submit_mult = $this->getMultipleFieldCommandType();
if (!empty($submit_mult)) {
if (isset($_REQUEST['selected_fld'])) {
if ($submit_mult == 'browse') {
// browsing the table displaying only selected columns