本文整理汇总了PHP中PMA\libraries\Util::sqlAddslashes方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::sqlAddslashes方法的具体用法?PHP Util::sqlAddslashes怎么用?PHP Util::sqlAddslashes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA\libraries\Util
的用法示例。
在下文中一共展示了Util::sqlAddslashes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_RTN_getQueryFromRequest
//.........这里部分代码省略.........
$warned_about_length = false;
if (!empty($_REQUEST['item_param_name']) && !empty($_REQUEST['item_param_type']) && !empty($_REQUEST['item_param_length']) && is_array($_REQUEST['item_param_name']) && is_array($_REQUEST['item_param_type']) && is_array($_REQUEST['item_param_length'])) {
$item_param_name = $_REQUEST['item_param_name'];
$item_param_type = $_REQUEST['item_param_type'];
$item_param_length = $_REQUEST['item_param_length'];
for ($i = 0, $nb = count($item_param_name); $i < $nb; $i++) {
if (!empty($item_param_name[$i]) && !empty($item_param_type[$i])) {
if ($_REQUEST['item_type'] == 'PROCEDURE' && !empty($_REQUEST['item_param_dir'][$i]) && in_array($_REQUEST['item_param_dir'][$i], $param_directions)) {
$params .= $_REQUEST['item_param_dir'][$i] . " " . PMA\libraries\Util::backquote($item_param_name[$i]) . " " . $item_param_type[$i];
} else {
if ($_REQUEST['item_type'] == 'FUNCTION') {
$params .= PMA\libraries\Util::backquote($item_param_name[$i]) . " " . $item_param_type[$i];
} else {
if (!$warned_about_dir) {
$warned_about_dir = true;
$errors[] = sprintf(__('Invalid direction "%s" given for parameter.'), htmlspecialchars($_REQUEST['item_param_dir'][$i]));
}
}
}
if ($item_param_length[$i] != '' && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|' . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|' . 'SERIAL|BOOLEAN)$@i', $item_param_type[$i])) {
$params .= "(" . $item_param_length[$i] . ")";
} else {
if ($item_param_length[$i] == '' && preg_match('@^(ENUM|SET|VARCHAR|VARBINARY)$@i', $item_param_type[$i])) {
if (!$warned_about_length) {
$warned_about_length = true;
$errors[] = __('You must provide length/values for routine parameters' . ' of type ENUM, SET, VARCHAR and VARBINARY.');
}
}
}
if (!empty($_REQUEST['item_param_opts_text'][$i])) {
if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'CHAR') {
$params .= ' CHARSET ' . mb_strtolower($_REQUEST['item_param_opts_text'][$i]);
}
}
if (!empty($_REQUEST['item_param_opts_num'][$i])) {
if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'NUMBER') {
$params .= ' ' . mb_strtoupper($_REQUEST['item_param_opts_num'][$i]);
}
}
if ($i != count($item_param_name) - 1) {
$params .= ", ";
}
} else {
$errors[] = __('You must provide a name and a type for each routine parameter.');
break;
}
}
}
$query .= "(" . $params . ") ";
if ($_REQUEST['item_type'] == 'FUNCTION') {
$item_returntype = isset($_REQUEST['item_returntype']) ? $_REQUEST['item_returntype'] : null;
if (!empty($item_returntype) && in_array($item_returntype, PMA\libraries\Util::getSupportedDatatypes())) {
$query .= "RETURNS " . $item_returntype;
} else {
$errors[] = __('You must provide a valid return type for the routine.');
}
if (!empty($_REQUEST['item_returnlength']) && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|' . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN)$@i', $item_returntype)) {
$query .= "(" . $_REQUEST['item_returnlength'] . ")";
} else {
if (empty($_REQUEST['item_returnlength']) && preg_match('@^(ENUM|SET|VARCHAR|VARBINARY)$@i', $item_returntype)) {
if (!$warned_about_length) {
$errors[] = __('You must provide length/values for routine parameters' . ' of type ENUM, SET, VARCHAR and VARBINARY.');
}
}
}
if (!empty($_REQUEST['item_returnopts_text'])) {
if ($PMA_Types->getTypeClass($item_returntype) == 'CHAR') {
$query .= ' CHARSET ' . mb_strtolower($_REQUEST['item_returnopts_text']);
}
}
if (!empty($_REQUEST['item_returnopts_num'])) {
if ($PMA_Types->getTypeClass($item_returntype) == 'NUMBER') {
$query .= ' ' . mb_strtoupper($_REQUEST['item_returnopts_num']);
}
}
$query .= ' ';
}
if (!empty($_REQUEST['item_comment'])) {
$query .= "COMMENT '" . PMA\libraries\Util::sqlAddslashes($_REQUEST['item_comment']) . "' ";
}
if (isset($_REQUEST['item_isdeterministic'])) {
$query .= 'DETERMINISTIC ';
} else {
$query .= 'NOT DETERMINISTIC ';
}
if (!empty($_REQUEST['item_sqldataaccess']) && in_array($_REQUEST['item_sqldataaccess'], $param_sqldataaccess)) {
$query .= $_REQUEST['item_sqldataaccess'] . ' ';
}
if (!empty($_REQUEST['item_securitytype'])) {
if ($_REQUEST['item_securitytype'] == 'DEFINER' || $_REQUEST['item_securitytype'] == 'INVOKER') {
$query .= 'SQL SECURITY ' . $_REQUEST['item_securitytype'] . ' ';
}
}
if (!empty($_REQUEST['item_definition'])) {
$query .= $_REQUEST['item_definition'];
} else {
$errors[] = __('You must provide a routine definition.');
}
return $query;
}
示例2: exportHeader
//.........这里部分代码省略.........
$result = $GLOBALS['dbi']->fetchResult('SHOW CREATE TABLE ' . Util::backquote($db) . '.' . Util::backquote($table), 0);
$tbl = $result[$table][1];
$is_view = $GLOBALS['dbi']->getTable($db, $table)->isView();
if ($is_view) {
$type = 'view';
} else {
$type = 'table';
}
if ($is_view && !isset($GLOBALS['xml_export_views'])) {
continue;
}
if (!$is_view && !isset($GLOBALS['xml_export_tables'])) {
continue;
}
$head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
$tbl = " " . htmlspecialchars($tbl);
$tbl = str_replace("\n", "\n ", $tbl);
$head .= $tbl . ';' . $crlf;
$head .= ' </pma:' . $type . '>' . $crlf;
if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
// Export triggers
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
if ($triggers) {
foreach ($triggers as $trigger) {
$code = $trigger['create'];
$head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
// Do some formatting
$code = mb_substr(rtrim($code), 0, -3);
$code = " " . htmlspecialchars($code);
$code = str_replace("\n", "\n ", $code);
$head .= $code . $crlf;
$head .= ' </pma:trigger>' . $crlf;
}
unset($trigger);
unset($triggers);
}
}
}
if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
// Export functions
$functions = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'FUNCTION');
if ($functions) {
foreach ($functions as $function) {
$head .= ' <pma:function name="' . $function . '">' . $crlf;
// Do some formatting
$sql = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $function);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
$head .= $sql . $crlf;
$head .= ' </pma:function>' . $crlf;
}
unset($function);
unset($functions);
}
}
if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
// Export procedures
$procedures = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'PROCEDURE');
if ($procedures) {
foreach ($procedures as $procedure) {
$head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
// Do some formatting
$sql = $GLOBALS['dbi']->getDefinition($db, 'PROCEDURE', $procedure);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
$head .= $sql . $crlf;
$head .= ' </pma:procedure>' . $crlf;
}
unset($procedure);
unset($procedures);
}
}
if (isset($GLOBALS['xml_export_events']) && $GLOBALS['xml_export_events']) {
// Export events
$events = $GLOBALS['dbi']->fetchResult("SELECT EVENT_NAME FROM information_schema.EVENTS " . "WHERE EVENT_SCHEMA='" . Util::sqlAddslashes($db) . "'");
if ($events) {
foreach ($events as $event) {
$head .= ' <pma:event name="' . $event . '">' . $crlf;
$sql = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);
$head .= $sql . $crlf;
$head .= ' </pma:event>' . $crlf;
}
unset($event);
unset($events);
}
}
unset($result);
$head .= ' </pma:database>' . $crlf;
$head .= ' </pma:structure_schemas>' . $crlf;
if ($export_data) {
$head .= $crlf;
}
}
return PMA_exportOutputHandler($head);
}