本文整理汇总了PHP中PMA_splitSqlFile函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_splitSqlFile函数的具体用法?PHP PMA_splitSqlFile怎么用?PHP PMA_splitSqlFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_splitSqlFile函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: claro_sql_multi_query
/**
* CLAROLINE mySQL query wrapper. It allows to send multiple query at once to SQl server in a single string
*
* @author Guillaume Lederer <guillaume@claroline.net>,
* @param string $sqlQueries - the string containing sql queries to apply
* @param bool $breakOnFailure - stop query execution if one query failed (default true)
* @return true on success, false on failure
* @deprecated since Claroline 1.9, use Claroline::getDatabase() and new classes
* in database/extra.lib.php instead
*/
function claro_sql_multi_query($sqlQueries, $breakOnFailure = true)
{
$queryArray = PMA_splitSqlFile($sqlQueries);
foreach ($queryArray as $theQuery) {
if (!$theQuery['empty']) {
if (true === $breakOnFailure && false === claro_sql_query($theQuery['query'])) {
return false;
}
}
}
return true;
}
示例2: mysql_query
}
$requete_type = '';
if (!empty($value['type'])) {
$requete_type = $value['type'];
}
if ($requete_type == 'insert') {
mysql_query($value['query'], $wiki->dblink);
}
}
break;
default:
break;
}
}
$tab_requete_sql = array();
PMA_splitSqlFile($tab_requete_sql, $sql_contenu, '');
foreach ($tab_requete_sql as $value) {
break;
$table_nom = '';
if (!empty($value['table_nom'])) {
$table_nom = $value['table_nom'];
}
$requete_type = '';
if (!empty($value['type'])) {
$requete_type = $value['type'];
}
if ($requete_type == 'create') {
$erreur = testerConfig($sortie_verif, 'Création table ' . $table_nom . '...', @mysql_query($value['query'], $dblink), 'Déjà créée ?', 0, $erreur);
} else {
if ($requete_type == 'alter') {
$erreur = testerConfig($sortie_verif, 'Modification structure table ' . $table_nom . '...', @mysql_query($value['query'], $dblink), 'Déjà modifiée ?', 0, $erreur);
示例3: define
}
define('PMA_CHK_DROP', 1);
/**
* Store a query as a bookmark before executing it?
*/
if (isset($SQLbookmark) && $sql_query != '') {
require_once './libraries/bookmark.lib.php';
$bfields = array('dbase' => $db, 'user' => $cfg['Bookmark']['user'], 'query' => urlencode($sql_query), 'label' => $bkm_label);
PMA_addBookmarks($bfields, $cfg['Bookmark'], isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false);
}
/**
* Executes the query
*/
if ($sql_query != '') {
$pieces = array();
PMA_splitSqlFile($pieces, $sql_query, PMA_MYSQL_INT_VERSION);
$pieces_count = count($pieces);
if ($pieces_count > 1) {
$is_multiple = TRUE;
}
// Copy of the cleaned sql statement for display purpose only (see near the
// beginning of "db_details.php" & "tbl_properties.php")
// You can either
// * specify the amount of maximum pieces per query (having max_*_length set to 0!) or
// * specify the amount of maximum chars per query (having max_*_pieces set to 0!)
// - max_nofile_* is used for any queries submitted via copy&paste in the textarea
// - max_file_* is used for any file-submitted query
if (!$cfg['VerboseMultiSubmit']) {
// Here be the values if the Verbose-Mode (see config.inc.php) is NOT activated
$max_nofile_length = 500;
$max_nofile_pieces = 0;
示例4: rex_read_sql_dump
/**
* Reads a file and split all statements in it.
*
* @param $file String Path to the SQL-dump-file
*/
function rex_read_sql_dump($file)
{
if (is_file($file) && is_readable($file)) {
$ret = array();
$sqlsplit = '';
$fileContent = file_get_contents($file);
PMA_splitSqlFile($sqlsplit, $fileContent, '');
if (is_array($sqlsplit)) {
foreach ($sqlsplit as $qry) {
$ret[] = $qry['query'];
}
}
return $ret;
}
return false;
}
示例5: file_get_contents
* Initialize test data?
*/
if (isset($_POST['pog_table']) && $_POST['pog_table'] == 'recreate_import') {
$initialData = file_get_contents('data_initialization/data_initialization.sql');
PMA_splitSqlFile($statements, $initialData, 4);
if (sizeof($statements) > 0) {
foreach ($statements as $statement) {
if (!TestExecuteQuery($statement['query'])) {
$errors++;
AddError('Statement "' . $statement['query'] . '" failed');
}
}
}
$structure_changes = file_get_contents('data_initialization/additional_table_structures.sql');
unset($statements);
PMA_splitSqlFile($statements, $structure_changes, 4);
if (sizeof($statements) > 0) {
foreach ($statements as $statement) {
if (!TestExecuteQuery($statement['query'])) {
$errors++;
AddError('Statement "' . $statement['query'] . '" failed');
}
}
}
}
/**
* verify object status
*/
$objectNameList = array();
foreach ($objects as $object) {
$objectName = GetObjectName("../objects/" . $object);
示例6: time
if ($release < 32270 && ($char == '!' && $i > 1 && $sql[$i - 2] . $sql[$i - 1] == '/*')) {
$sql[$i] = ' ';
}
}
}
}
}
// end else if
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
$time0 = $time1;
header('X-pmaPing: Pong');
}
// end if
}
// end for
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = $sql;
}
return TRUE;
}
// end of the 'PMA_splitSqlFile()' function
SFile::setRoot($config['basedir'] . "/install");
$queries = SFile::read("db.sql");
PMA_splitSqlFile($queries_ar, $queries, 0);
foreach ($queries_ar as $query) {
mysql_query($query);
}
//SDatabase::getErrors(true);
示例7: array
<?php
include "helper.php";
$errors = array();
$goToNextStep = false;
$host = $_SESSION['db_host'];
$username = $_SESSION['db_user'];
$password = $_SESSION['db_pass'];
$database = $_SESSION['db_name'];
// connect to db
$con = mysql_connect($host, $username, $password);
mysql_select_db($database, $con);
// read import sql
$import = file_get_contents("config/import.sql");
$queries = array();
PMA_splitSqlFile($queries, $import);
foreach ($queries as $query) {
if (!mysql_query($query['query'])) {
$errors[] = "<b>" . mysql_error() . "</b><br>(" . substr($query['query'], 0, 200) . "...)";
}
}
// close connection
mysql_close($con);
// show error
include "templates/importSQL.php";
示例8: mysql_connect
$sql1 = '../install/data_tables.php';
$sql2 = '../install/data_templates.php';
$connection = mysql_connect($set['db_host'], $set['db_user'], $set['db_pass']);
mysql_select_db($db);
// Structure
$table_select1 = array("{$prefix}active" => 1, "{$prefix}attach" => 1, "{$prefix}forums" => 1, "{$prefix}groups" => 1, "{$prefix}help" => 1, "{$prefix}logs" => 1, "{$prefix}membertitles" => 1, "{$prefix}pmsystem" => 1, "{$prefix}posts" => 1, "{$prefix}replacements" => 1, "{$prefix}settings" => 1, "{$prefix}skins" => 1, "{$prefix}subscriptions" => 1, "{$prefix}templates" => 1, "{$prefix}timezones" => 1, "{$prefix}topics" => 1, "{$prefix}users" => 1, "{$prefix}votes" => 1);
// Data
$table_select2 = array("{$prefix}groups" => 1, "{$prefix}help" => 1, "{$prefix}membertitles" => 1, "{$prefix}replacements" => 1, "{$prefix}settings" => 1, "{$prefix}skins" => 1, "{$prefix}timezones" => 1, "{$prefix}users" => 1);
$dump1 = makedump($table_select1, 'structure', $db);
$dump1 .= makedump($table_select2, 'dataonly', $db);
$dump2 = makedump(array("{$prefix}templates" => 1), 'dataonly', $db);
define_mysql_version();
$queries1 = array();
$queries2 = array();
PMA_splitSqlFile($queries1, $dump1, PMA_MYSQL_INT_VERSION);
PMA_splitSqlFile($queries2, $dump2, PMA_MYSQL_INT_VERSION);
$out1 = '<?php
/**
* Quicksilver Forums
* Copyright (c) 2005 The Quicksilver Forums Development Team
* http://www.quicksilverforums.com/
*
* based off MercuryBoard
* Copyright (c) 2001-2005 The Mercury Development Team
* http://www.mercuryboard.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
示例9: executeSqlScript
/**
* Execute a SQL script
*
* @param $script, string : the CMS_file::FILE_SYSTEM SQL script filename
* This script can be SQL export provided by phpMyadmin or mysqldump, etc.
* @param simulation : boolean, if true, only do a read of the script and if it contain sql data, return true.
* @return boolean, true on success, false on failure
* @access public
*/
function executeSqlScript($script, $simulation = false)
{
//include PMA import functions
require_once PATH_PACKAGES_FS . '/files/sqlDump.php';
//read mysql version and set needed constant/vars for phpMyAdmin
$q = new CMS_query('SELECT VERSION() AS version');
$version = $q->getValue('version');
$match = explode('.', $version);
//read mysql file
$query = PMA_readFile($script);
//first, detect SQL file encoding
$isUTF8 = io::isUTF8($query);
//then, change charset declaration inside sql queries to match current Automne charset
if (strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
//if Automne is not in utf8, then table charset must be in latin1
$query = str_ireplace(' CHARSET=utf8', ' CHARSET=latin1', $query);
$query = str_ireplace('TYPE=MyISAM;', 'TYPE=MyISAM CHARSET=latin1;', $query);
} else {
//if Automne is in utf8, then table charset must be in utf8
$query = str_ireplace(' CHARSET=latin1', ' CHARSET=utf8', $query);
$query = str_ireplace('TYPE=MyISAM;', 'TYPE=MyISAM CHARSET=utf8;', $query);
}
//finally, clean it and split queries
PMA_splitSqlFile($queries, $query, (int) sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
if (!$simulation) {
//set connection charset accordingly to file charset
if ($isUTF8) {
$q = new CMS_query("SET NAMES 'utf8'");
} else {
$q = new CMS_query("SET NAMES 'latin1'");
}
//execute all queries
$ok = true;
foreach ($queries as $aQuery) {
$q = new CMS_query($aQuery);
$ok = $q->hasError() ? false : $ok;
}
//set connection charset accordingly to file charset
if ($isUTF8) {
$q = new CMS_query("SET NAMES 'latin1'");
} else {
$q = new CMS_query("SET NAMES 'utf8'");
}
} else {
$ok = is_array($queries) && $queries ? true : false;
}
//reset connection charset
if (io::strtolower(APPLICATION_DEFAULT_ENCODING) == 'utf-8') {
//set connection to utf-8 charset
$q = new CMS_query("SET NAMES 'utf8'");
} else {
$q = new CMS_query("SET NAMES 'latin1'");
}
return $ok;
}
示例10: mysql_connect
$goToNextStep = false;
$host = $_SESSION['db_host'];
$username = $_SESSION['db_user'];
$password = $_SESSION['db_pass'];
$database = $_SESSION['db_name'];
// connect to db
$con = mysql_connect($host, $username, $password);
mysql_set_charset("UTF8", $con);
mysql_select_db($database, $con);
// read structure sql
$structure = file_get_contents("config/structure.sql");
$queries = array();
PMA_splitSqlFile($queries, $structure);
foreach ($queries as $query) {
if (!mysql_query($query['query'])) {
$errors[] = "<b>" . mysql_error() . "</b><br>(" . substr($query['query'], 0, 200) . "...)";
}
}
// read data sql
$data = file_get_contents("config/data.sql");
$queries = array();
PMA_splitSqlFile($queries, $data);
foreach ($queries as $query) {
if (!mysql_query($query['query'])) {
$errors[] = "<b>" . mysql_error() . "</b><br>(" . substr($query['query'], 0, 200) . "...)";
}
}
// close connection
mysql_close($con);
// show error
include "templates/importSQL.php";
示例11: rex_a1_import_db
/**
* Importiert den SQL Dump $filename in die Datenbank
*
* @param string Pfad + Dateinamen zur SQL-Datei
*
* @return array Gibt ein Assoc. Array zurück.
* 'state' => boolean (Status ob fehler aufgetreten sind)
* 'message' => Evtl. Status/Fehlermeldung
*/
function rex_a1_import_db($filename)
{
global $REX, $I18N;
$return = array();
$return['state'] = false;
$return['message'] = '';
$msg = '';
$error = '';
if ($filename == '' || substr($filename, -4, 4) != '.sql') {
$return['message'] = $I18N->msg('im_export_no_import_file_chosen_or_wrong_version') . '<br>';
return $return;
}
$conts = rex_get_file_contents($filename);
// Alle Importe die noch Type statt Engine haben ändern. Ab MySQL 5.4.4
if (version_compare($REX['MYSQL_VERSION'], '5.4.3', '>')) {
$conts = preg_replace('/\\bTYPE\\s*=\\s*(MyISAM|InnoDB)\\b/i', 'ENGINE=$1', $conts);
}
// Versionsstempel prüfen
// ## Redaxo Database Dump Version x.x
$version = strpos($conts, '## Redaxo Database Dump Version ' . $REX['VERSION']);
if ($version === false) {
$return['message'] = $I18N->msg('im_export_no_valid_import_file') . '. [## Redaxo Database Dump Version ' . $REX['VERSION'] . '] is missing';
return $return;
}
// Versionsstempel entfernen
$conts = trim(str_replace('## Redaxo Database Dump Version ' . $REX['VERSION'], '', $conts));
// Prefix prüfen
// ## Prefix xxx_
if (preg_match('/^## Prefix ([a-zA-Z0-9\\_]*)/', $conts, $matches) && isset($matches[1])) {
// prefix entfernen
$prefix = $matches[1];
$conts = trim(str_replace('## Prefix ' . $prefix, '', $conts));
} else {
// Prefix wurde nicht gefunden
$return['message'] = $I18N->msg('im_export_no_valid_import_file') . '. [## Prefix ' . $REX['TABLE_PREFIX'] . '] is missing';
return $return;
}
// Charset prüfen
// ## charset xxx_
if (preg_match('/^## charset ([a-zA-Z0-9\\_\\-]*)/', $conts, $matches) && isset($matches[1])) {
// charset entfernen
$charset = $matches[1];
$conts = trim(str_replace('## charset ' . $charset, '', $conts));
if ($I18N->msg('htmlcharset') == 'utf-8' and $charset != 'utf-8') {
$conts = utf8_encode($conts);
} elseif ($I18N->msg('htmlcharset') != $charset) {
$return['message'] = $I18N->msg('im_export_no_valid_charset') . '. ' . $I18N->msg('htmlcharset') . ' != ' . $charset;
return $return;
}
}
// Prefix im export mit dem der installation angleichen
if ($REX['TABLE_PREFIX'] != $prefix) {
// Hier case-insensitiv ersetzen, damit alle möglich Schreibweisen (TABLE TablE, tAblE,..) ersetzt werden
// Dies ist wichtig, da auch SQLs innerhalb von Ein/Ausgabe der Module vom rex-admin verwendet werden
$conts = preg_replace('/(TABLES? `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(INTO `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(EXISTS `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
}
// ----- EXTENSION POINT
$filesize = filesize($filename);
$msg = rex_register_extension_point('A1_BEFORE_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
// require import skript to do some userside-magic
rex_a1_import_skript(str_replace('.sql', '.php', $filename), REX_A1_IMPORT_DB, REX_A1_IMPORT_EVENT_PRE);
if (!function_exists('PMA_splitSqlFile')) {
include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_addons.inc.php';
}
// Datei aufteilen
$lines = array();
PMA_splitSqlFile($lines, $conts, 0);
$sql = rex_sql::factory();
foreach ($lines as $line) {
$line['query'] = trim($line['query']);
if (strpos($line['query'], 'CREATE TABLE') === 0 and !strpos($line['query'], 'DEFAULT CHARSET')) {
$line['query'] .= ' DEFAULT CHARSET=utf8';
}
$sql->setQuery($line['query']);
if ($sql->hasError()) {
$error .= "\n" . $sql->getError();
}
}
if ($error != '') {
$return['message'] = trim($error);
return $return;
}
$msg .= $I18N->msg('im_export_database_imported') . '. ' . $I18N->msg('im_export_entry_count', count($lines)) . '<br />';
unset($lines);
// prüfen, ob eine user tabelle angelegt wurde
$tables = rex_sql::showTables();
$user_table_found = in_array($REX['TABLE_PREFIX'] . 'user', $tables);
if (!$user_table_found) {
$create_user_table = '
//.........这里部分代码省略.........