当前位置: 首页>>代码示例>>PHP>>正文


PHP split_sql函数代码示例

本文整理汇总了PHP中split_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP split_sql函数的具体用法?PHP split_sql怎么用?PHP split_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了split_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: installdb

function installdb()
{
    global $prefix, $db_name;
    mysql_select_db($db_name) or die("ERROR: " . mysql_error());
    $sql_query = addslashes(fread(fopen("phpBazar.sql", "r"), filesize("phpBazar.sql")));
    $pieces = split_sql($sql_query);
    if (count($pieces) == 1 && !empty($pieces[0])) {
        echo "Error !!!";
    }
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = stripslashes(trim($pieces[$i]));
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            $pieces[$i] = str_replace("IF EXISTS ", "IF EXISTS " . $prefix, $pieces[$i]);
            $pieces[$i] = str_replace("CREATE TABLE ", "CREATE TABLE " . $prefix, $pieces[$i]);
            $pieces[$i] = str_replace("INSERT INTO ", "INSERT INTO " . $prefix, $pieces[$i]);
            $result = mysql_query($pieces[$i]);
            if (!$result) {
                echo "Database: [{$db_name}] - MYSQL-ERROR: " . mysql_error() . "<br>Command: " . stripslashes($pieces[$i]) . "<br>";
            } else {
                echo "Database: [{$db_name}] - mySQL-command: <b>OK!</b><br>";
            }
        }
    }
    echo "<br><b>Logix Classifieds Tables installed, Ready ...</b>";
}
开发者ID:BackupTheBerlios,项目名称:logixclassified-svn,代码行数:25,代码来源:setup.php

示例2: populate_database

/**
 * Following two functions populate_database() and split_sql() were taken from Joomla!
 * From the file /installation/installer/helper.php of release 1.5.6
 */
function populate_database($sqlfile)
{
    if (!($buffer = file_get_contents($sqlfile))) {
        return -1;
    }
    $queries = split_sql($buffer);
    foreach ($queries as $query) {
        $query = trim($query);
        if ($query != '' && $query[0] != '#') {
            mysql_query($query);
            if (mysql_error()) {
                die(mysql_error());
            }
        }
    }
}
开发者ID:google-code-backups,项目名称:swifttide,代码行数:20,代码来源:create_database.php

示例3: crear_db

function crear_db($DBname, $sqlfile = 'MaxCodecaRev.sql')
{
    mysql_select_db($DBname);
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $query = fread(fopen("./" . $sqlfile, "r"), filesize("./" . $sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);
    $errors = array();
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            if (!($result = mysql_query($pieces[$i]))) {
                $errors[] = array(mysql_error(), $pieces[$i]);
            }
        }
    }
}
开发者ID:joanlaga,项目名称:MaxCodekaRev,代码行数:18,代码来源:paso2.php

示例4: updateConfig

function updateConfig($module, $newsql)
{
    global $db, $set;
    //Aktuelle Werte auslesen
    $olddata = $db->fetch("SELECT varname, value FROM " . PRE . "_config WHERE module='" . addslashes($module) . "'");
    //Alte Einträge entfernen und neue einfügen
    $db->query("DELETE FROM " . PRE . "_config WHERE module='" . addslashes($module) . "'");
    $queries = split_sql($newsql);
    foreach ($queries as $query) {
        $db->query($query);
    }
    //Aktuelle Werte übernehmen
    if (count($olddata)) {
        foreach ($olddata as $res) {
            $db->query("\n\t\t\t\tUPDATE " . PRE . "_config\n\t\t\t\tSET value='" . addslashes($res['value']) . "'\n\t\t\t\tWHERE module='" . addslashes($module) . "' AND varname='" . addslashes($res['varname']) . "'\n\t\t\t");
        }
    }
}
开发者ID:bigfraggle,项目名称:open-apexx,代码行数:18,代码来源:functions.setup.php

示例5: populate_db

function populate_db(&$database, $sqlfile = 'creermonjeu.sql')
{
    global $errors;
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $query = fread(fopen('sql/' . $sqlfile, 'r'), filesize('sql/' . $sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            $database->setQuery($pieces[$i]);
            if (!$database->query()) {
                $errors[] = array($database->getErrorMsg(), $pieces[$i]);
            }
        }
    }
}
开发者ID:ezioms,项目名称:RpgEditor,代码行数:18,代码来源:install2.php

示例6: populate_db

/**
 * @param object
 * @param string File name
 */
function populate_db($database, $sqlfile='db_sistem.sql',$sistem=1) {
	global $errors;

	$mqr = @get_magic_quotes_runtime();
	@set_magic_quotes_runtime(0);
        if ($sistem)
            $sqlfile = 'sql/' . $sqlfile;
	$query = fread( fopen($sqlfile, 'r' ), filesize($sqlfile) );
	@set_magic_quotes_runtime($mqr);
	$pieces  = split_sql($query);

	for ($i=0; $i<count($pieces); $i++) {
		$pieces[$i] = trim($pieces[$i]);
		if(!empty($pieces[$i]) && $pieces[$i] != "#") {
			if (!mysql_query($pieces[$i],$database)) 
                $errors[] = mysql_error($database); 
		}
	}
}
开发者ID:nenpenthes,项目名称:Ext-PHP,代码行数:23,代码来源:install_function.php

示例7: populate_db

function populate_db($DBname, $sqlfile, $host, $user, $password)
{
    $link = mysql_connect($host, $user, $password);
    mysql_select_db($DBname, $link);
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $query = fread(fopen("includes/" . $sqlfile, "r"), filesize("includes/" . $sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);
    $errors = array();
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            if (!($result = mysql_query($pieces[$i]))) {
                $errors[] = array(mysql_error(), $pieces[$i]);
            }
        }
    }
}
开发者ID:danbocuto,项目名称:nblogproject,代码行数:19,代码来源:install_functions.php

示例8: INT

            //Zu 1.0.2
            $mysql = "\n\t\t\t\tALTER TABLE `apx_links` ADD `broken` INT( 11 ) UNSIGNED NOT NULL AFTER `endtime` ;\n\t\t\t";
            $queries = split_sql($mysql);
            foreach ($queries as $query) {
                $db->query($query);
            }
        case 102:
            //Zu 1.1.0
            //Indizes entfernen
            clearIndices(PRE . '_links');
            clearIndices(PRE . '_links_cat');
            //Tabellenformat ändern
            convertRecursiveTable(PRE . '_links_cat');
            //config Update
            updateConfig('links', "\n\t\t\t\tINSERT INTO `apx_config` (`module`, `varname`, `type`, `addnl`, `value`, `tab`, `lastchange`, `ord`) VALUES\n\t\t\t\t('links', 'epp', 'int', '', '20', 'VIEW', 1249981968, 1000),\n\t\t\t\t('links', 'searchepp', 'string', '', '20', 'VIEW', 1249981881, 2000),\n\t\t\t\t('links', 'catonly', 'switch', '', '1', 'VIEW', 1249981968, 3000),\n\t\t\t\t('links', 'sortby', 'select', 'a:2:{i:1;s:7:\"{TITLE}\";i:2;s:6:\"{DATE}\";}', '1', 'VIEW', 1249981968, 4000),\n\t\t\t\t('links', 'new', 'int', '', '3', 'VIEW', 1249981968, 5000),\n\t\t\t\t\n\t\t\t\t('links', 'searchable', 'switch', '', '1', 'OPTIONS', 1249981968, 1000),\n\t\t\t\t('links', 'coms', 'switch', '', '1', 'OPTIONS', 1249981968, 2000),\n\t\t\t\t('links', 'ratings', 'switch', '', '1', 'OPTIONS', 1249981968, 3000),\n\t\t\t\t('links', 'captcha', 'switch', '', '1', 'OPTIONS', 1249981968, 4000),\n\t\t\t\t('links', 'spamprot', 'int', '', '1', 'OPTIONS', 1249981968, 5000),\n\t\t\t\t('links', 'mailonnew', 'string', '', '', 'OPTIONS', 1249981968, 6000),\n\t\t\t\t('links', 'mailonbroken', 'string', '', '', 'OPTIONS', 1249981968, 7000),\n\t\t\t\t\n\t\t\t\t('links', 'linkpic_width', 'int', '', '120', 'IMAGES', 1249981968, 1000),\n\t\t\t\t('links', 'linkpic_height', 'int', '', '120', 'IMAGES', 1249981968, 2000),\n\t\t\t\t('links', 'linkpic_popup', 'switch', '', '1', 'IMAGES', 1249981968, 3000),\n\t\t\t\t('links', 'linkpic_popup_width', 'int', '', '640', 'IMAGES', 1249981968, 4000),\n\t\t\t\t('links', 'linkpic_popup_height', 'int', '', '480', 'IMAGES', 1249981968, 5000),\n\t\t\t\t('links', 'linkpic_quality', 'switch', '', '1', 'IMAGES', 1249981968, 6000);\n\t\t\t");
            $mysql = "\n\t\t\t\tCREATE TABLE `apx_links_tags` (\n\t\t\t\t\t`id` INT( 11 ) UNSIGNED NOT NULL ,\n\t\t\t\t\t`tagid` INT( 11 ) UNSIGNED NOT NULL ,\n\t\t\t\t\tPRIMARY KEY ( `id` , `tagid` )\n\t\t\t\t) ENGINE=MyISAM;\n\t\t\t\t\n\t\t\t\tALTER TABLE `apx_links` ADD `restricted` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `allowrating` ;\n\t\t\t\t\n\t\t\t\tALTER TABLE `apx_links` ADD INDEX ( `catid` ) ;\n\t\t\t\tALTER TABLE `apx_links` ADD INDEX ( `userid` ) ;\n\t\t\t\tALTER TABLE `apx_links` ADD INDEX ( `starttime` , `endtime` ) ;\n\t\t\t\tALTER TABLE `apx_links_cat` ADD INDEX ( `parents` ) ;\n\t\t\t";
            $queries = split_sql($mysql);
            foreach ($queries as $query) {
                $db->query($query);
            }
            //Tags erzeugen
            transformKeywords(PRE . '_links', PRE . '_links_tags');
        case 110:
            //Zu 1.1.1
            $mysql = "\n\t\t\t\tALTER TABLE `apx_links` ADD `meta_description` TEXT NOT NULL AFTER `text` ;\n\t\t\t";
            $queries = split_sql($mysql);
            foreach ($queries as $query) {
                $db->query($query);
            }
    }
}
开发者ID:bigfraggle,项目名称:open-apexx,代码行数:31,代码来源:setup.php

示例9: populate_db

function populate_db($DBname, $DBPrefix, $sqlfile = 'dbsetup.sql')
{
    global $errors;
    mysql_select_db($DBname);
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $query = fread(fopen("sql/" . $sqlfile, "r"), filesize("sql/" . $sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            $pieces[$i] = str_replace("#__", $DBPrefix, $pieces[$i]);
            if (!($result = mysql_query($pieces[$i]))) {
                $errors[] = array(mysql_error(), $pieces[$i]);
            }
        }
    }
}
开发者ID:jeroenrnl,项目名称:php-syslog-ng,代码行数:19,代码来源:install2.php

示例10: populate_db

function populate_db($db, $sqlfile = 'administrator/backups/database-sql.sql')
{
    global $errors, $_CONFIG;
    if ($_REQUEST['use_mysqldump'] == 1) {
        echo shell_exec($_REQUEST['mysqldump_path'] . " -u " . $_REQUEST[mysql_username] . " -p" . $_REQUEST[mysql_pass] . " -h " . $_REQUEST[mysql_server] . " " . $_REQUEST[mysql_db] . " < " . $sqlfile);
        return;
    }
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    @chmod($sqlfile, 0777);
    $query = fread(fopen($sqlfile, 'r'), filesize($sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        $tmp = explode("DEFAULT CHARSET", $pieces[$i]);
        $pieces[$i] = $tmp[0] . ";";
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            if (!$_CONFIG['mysqli']->query($pieces[$i], $db)) {
                $errors[] = "\n\n##Mysql Query: \n########\n" . $pieces[$i] . "\n########\n##Error message: " . $_CONFIG['mysqli']->error;
            }
        }
    }
    return $errors;
}
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:25,代码来源:XCloner.php

示例11: populate_mysql_db

function populate_mysql_db($sql)
{
    $sql = split_sql($sql, "exec_sql");
}
开发者ID:Staalkoper,项目名称:microweber-hosting-scripts,代码行数:4,代码来源:db-util.php

示例12: pg_connect

 $con = pg_connect("host={$dbip} dbname={$dbname} user={$usr} password={$pass} connect_timeout=3");
 if (pg_last_error()) {
     throw new Exception('When trying to connect to POSTGRES database: <br/>' . pg_last_error());
 }
 $response = array();
 foreach ($sqls as $name => $sql) {
     // for every sequel in the hash
     $sql = trim($sql);
     if (!preg_match("/.*LIMIT\\s+\\d+\\s*;?\$/i", $sql)) {
         //throw new Exception("No trailing LIMIT-clause found for serie '$name'...<br/>SQL: '$sql'<br/>Example: add 'LIMIT 1000' at the end...");
     }
     $sql = preg_replace('/\\s*?--\\s*?.*/', '', $sql);
     // remove comments
     $sql = str_replace(array("\n", "\t"), '', $sql);
     // remove newlines en tabs
     $queries = split_sql($sql);
     $nested = 0;
     foreach ($queries as $query) {
         if (strlen(trim($query)) > 0) {
             $escaped_query = $query;
             //pg_escape_string($con, $query);
             $result = pg_query($con, $query);
             $nested_suffix = $nested == 0 ? "" : "_" . $nested;
             if (pg_last_error()) {
                 throw new Exception('When executing POSTGRES query: <br/>' . pg_last_error() . '<br/><br/>Make sure you doublequote your tablename, and check case sensitivity.');
             }
             $resultset = array();
             while ($row = pg_fetch_row($result)) {
                 array_push($resultset, array($row[0], $row[1]));
             }
             if (count($resultset) != 0) {
开发者ID:vsercu,项目名称:vivi,代码行数:31,代码来源:live-server-data.php

示例13: install_insert_db

/**
 * install_insert_db
 *
 * Inserts the database using the values from Config.
 */
function install_insert_db($db_user = null, $db_pass = null, $create_db = true, $overwrite = false, $create_tables = true)
{
    $database = AmpConfig::get('database_name');
    // Make sure that the database name is valid
    preg_match('/([^\\d\\w\\_\\-])/', $database, $matches);
    if (count($matches)) {
        Error::add('general', T_('Error: Invalid database name.'));
        return false;
    }
    if (!Dba::check_database()) {
        Error::add('general', sprintf(T_('Error: Unable to make database connection: %s'), Dba::error()));
        return false;
    }
    $db_exists = Dba::read('SHOW TABLES');
    if ($db_exists && $create_db) {
        if ($overwrite) {
            Dba::write('DROP DATABASE `' . $database . '`');
        } else {
            Error::add('general', T_('Error: Database already exists and overwrite not checked'));
            return false;
        }
    }
    if ($create_db) {
        if (!Dba::write('CREATE DATABASE `' . $database . '`')) {
            Error::add('general', sprintf(T_('Error: Unable to create database: %s'), Dba::error()));
            return false;
        }
    }
    Dba::disconnect();
    // Check to see if we should create a user here
    if (strlen($db_user) && strlen($db_pass)) {
        $db_host = AmpConfig::get('database_hostname');
        $sql = 'GRANT ALL PRIVILEGES ON `' . Dba::escape($database) . '`.* TO ' . "'" . Dba::escape($db_user) . "'";
        if ($db_host == 'localhost' || strpos($db_host, '/') === 0) {
            $sql .= "@'localhost'";
        }
        $sql .= "IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION";
        if (!Dba::write($sql)) {
            Error::add('general', sprintf(T_('Error: Unable to create user %1$s with permissions to %2$s on %3$s: %4$s'), $db_user, $database, $db_host, Dba::error()));
            return false;
        }
    }
    // end if we are creating a user
    if ($create_tables) {
        $sql_file = AmpConfig::get('prefix') . '/sql/ampache.sql';
        $query = fread(fopen($sql_file, 'r'), filesize($sql_file));
        $pieces = split_sql($query);
        $errors = array();
        for ($i = 0; $i < count($pieces); $i++) {
            $pieces[$i] = trim($pieces[$i]);
            if (!empty($pieces[$i]) && $pieces[$i] != '#') {
                if (!($result = Dba::write($pieces[$i]))) {
                    $errors[] = array(Dba::error(), $pieces[$i]);
                }
            }
        }
    }
    if ($create_db) {
        $sql = 'ALTER DATABASE `' . $database . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci';
        Dba::write($sql);
    }
    // If they've picked something other than English update default preferences
    if (AmpConfig::get('lang') != 'en_US') {
        // FIXME: 31? I hate magic.
        $sql = 'UPDATE `preference` SET `value`= ? WHERE `id` = 31';
        Dba::write($sql, array(AmpConfig::get('lang')));
        $sql = 'UPDATE `user_preference` SET `value` = ? WHERE `preference` = 31';
        Dba::write($sql, array(AmpConfig::get('lang')));
    }
    return true;
}
开发者ID:nioc,项目名称:ampache,代码行数:76,代码来源:install.lib.php

示例14: fopen

    return $ret;
}
// Definicion de variables para almacenar resultado
$estado_final = "0";
$accion = "";
include_once "dev_tools/tests/t_bdconfig.php";
include_once "core/conexiones.php";
include_once "core/comunes.php";
//PASO 1: Agrega las tablas y ejecuta consultas iniciales sobre la base de datos
$total_ejecutadas = 0;
//Abre el archivo con los queries dependiendo del motor
$RutaScriptSQL = "ins/sql/practico." . $MotorBD;
$archivo_consultas = fopen($RutaScriptSQL, "r");
$total_consultas = fread($archivo_consultas, filesize($RutaScriptSQL));
fclose($archivo_consultas);
$arreglo_consultas = split_sql($total_consultas);
foreach ($arreglo_consultas as $consulta) {
    try {
        //Ejecuta el query
        $consulta_enviar = $ConexionPDO->prepare($consulta);
        $consulta_enviar->execute();
        $total_ejecutadas++;
    } catch (PDOException $ErrorPDO) {
        echo "SQL: " . $consulta . " ==>> " . $ErrorPDO->getMessage();
        $hay_error = 1;
    }
}
//PASO 2: Verifica las tablas creadas en la base de datos
$resultado = consultar_tablas();
$total_tablas = 0;
while ($registro = $resultado->fetch()) {
开发者ID:afgstec,项目名称:practico,代码行数:31,代码来源:t_basedatos.php

示例15: populate_db

/**
 * @param object
 * @param string File name
 */
function populate_db(&$database, $sqlfile = 'nuke.sql')
{
    global $errors;
    $query = fread(fopen('sql/' . $sqlfile, 'r'), filesize('sql/' . $sqlfile));
    $pieces = split_sql($query);
    for ($i = 0; $i < count($pieces); $i++) {
        $pieces[$i] = trim($pieces[$i]);
        if (!empty($pieces[$i]) && $pieces[$i] != "#") {
            $database->setQuery($pieces[$i]);
            if (!$database->query()) {
                $errors[] = array($database->getErrorMsg(), $pieces[$i]);
            }
        }
    }
}
开发者ID:rotvulpix,项目名称:php-nuke,代码行数:19,代码来源:install2.php


注:本文中的split_sql函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。