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


PHP splitsql函数代码示例

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


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

示例1: upgrade

 public function upgrade()
 {
     $this->Purview_model->checkPurview($this->tablefunc, 'upgrade');
     if ($this->input->post('action')) {
         $upgradesql = trim($this->input->post('upgradesql', TRUE));
         if ($upgradesql) {
             $sqlarr = splitsql($upgradesql);
             foreach ($sqlarr as $sql) {
                 $this->db->query($sql);
             }
             show_jsonmsg(array('status' => 200));
         } else {
             show_jsonmsg(array('status' => 200, 'remsg' => lang('database_sqlerror')));
         }
     } else {
         $res = array('tpl' => 'upgrade', 'tablefunc' => $this->tablefunc, 'funcstr' => $this->Purview_model->getFunc($this->tablefunc, array('upgrade')));
         $this->load->view($this->tablefunc, $res);
     }
 }
开发者ID:pondyond,项目名称:x6cms,代码行数:19,代码来源:database.php

示例2: runquery

function runquery($queries){//执行sql语句
	global $tablepre,$whereis;
	$sqlquery = splitsql(str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $queries));
	$affected_rows = 0;
	foreach($sqlquery as $sql) {
	$sql = syntablestruct(trim($sql), $my_version > '4.1', $dbcharset);
	if(trim($sql) != '') {
		mysql_query(stripslashes($sql));
		if($sqlerror = mysql_error()) {
			break;
			} else {
			$affected_rows += intval(mysql_affected_rows());
			}
		}
	}
	if(strpos($queries,'seccodestatus') && $whereis == 'is_dz') {
		dz_updatecache();	
	}
	if(strpos($queries,'bbclosed') && $whereis == 'is_dz') {
		dz_updatecache();	
	}
	if(strpos($queries,'template') && $whereis == 'is_uch') {
		uch_updatecache();	
	}
	if(strpos($queries,'seccode_login') && $whereis == 'is_uch') {
		uch_updatecache();	
	}
	if(strpos($queries,'close') && $whereis == 'is_uch') {
		uch_updatecache();	
	}
	errorpage($sqlerror? $sqlerror : "数据库升级成功,影响行数:  $affected_rows",'数据库升级');

	if(strpos($queries,'settings') && $whereis == 'is_dz') {
		require_once './include/cache.func.php';
		updatecache('settings');		
	}
}
开发者ID:noikiy,项目名称:ejia,代码行数:37,代码来源:tools.php

示例3: flash

        } else {
            flash();
        }
    }
}
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if ($do == "refresh" && !empty($_GET['id'])) {
        $datafile = DATA_PATH . "backup_" . $backupdir . DS . $_GET['id'];
        if (!file_exists($datafile)) {
            flash("file_not_exists");
        } else {
            if (@($fp = fopen($datafile, 'rb'))) {
                $sqldump = fread($fp, filesize($datafile));
                fclose($fp);
                $sqlquery = splitsql($sqldump);
                unset($sqldump);
                foreach ($sqlquery as $sql) {
                    $sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
                    if ($sql != '') {
                        $db->query($sql);
                        if (($sqlerror = $db->error()) && $db->errno() != 1062) {
                            $db->halt('MySQL Query Error', $sql);
                        }
                    }
                }
                flash("db_restored", "db.php?do=restore");
            } else {
                flash();
            }
        }
开发者ID:renduples,项目名称:alibtob,代码行数:31,代码来源:db.php

示例4: intval

<br /><center><input class="button" type="submit" name="sqlsubmit" value="<?=$lang['submit']?>"></center>
</form></td></tr>
<?

		}

	} else {

		if($option == 'simple') {
			$queryselect = intval($queryselect);
			$queries = isset($simplequeries[$queryselect]) && $simplequeries[$queryselect]['sql'] ? $simplequeries[$queryselect]['sql'] : '';
		} elseif(!$checkperm) {
			cpmsg('database_run_query_denied');
		}

		$sqlquery = splitsql(str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $queries));
		$affected_rows = 0;
		foreach($sqlquery as $sql) {
			if(trim($sql) != '') {
				$db->query(stripslashes($sql), 'SILENT');
				if($sqlerror = $db->error()) {
					break;
				} else {
					$affected_rows += intval($db->affected_rows());
				}
			}
		}

		cpmsg($sqlerror ? 'database_run_query_invalid' : 'database_run_query_succeed');
	}
开发者ID:jonycookie,项目名称:projectm2,代码行数:30,代码来源:database.inc.php

示例5: adminlog

            $tablestr .= ($tablestr ? ',' : '') . $tblprefix . $table;
        }
        $tablestr && $db->query("{$dealstr} TABLE {$tablestr}");
        adminlog(lang('db_tb_' . submitcheck('bdboptimize') ? 'optimize' : 'repair'));
        amessage('tableoperatefinish', '?entry=database&action=dboptimize');
    }
} elseif ($action == 'dbsql') {
    if (!submitcheck('bdbsql')) {
        url_nav(lang('dboperate'), $urlsarr, 'dbsql');
        tabheader(lang('run_sql_code'), 'dbsql', '?entry=database&action=dbsql');
        echo "<tr class=\"txt\"><td class=\"txtL w25B\">" . lang('im_sql_code_content') . "</td><td class=\"txtL\"><textarea rows=\"15\" name=\"sqlcode\" cols=\"100\"></textarea></td></tr>";
        tabfooter('bdbsql');
        a_guide('dbsql');
    } else {
        empty($sqlcode) && amessage('inputsqlcode', '?entry=database&action=dbsql');
        $sqlquery = splitsql(str_replace(array(' cms_', ' {tblprefix}', ' `cms_'), array(' ' . $tblprefix, ' ' . $tblprefix, ' `' . $tblprefix), $sqlcode));
        $affected_rows = 0;
        foreach ($sqlquery as $sql) {
            if (trim($sql) != '') {
                $db->query(stripslashes($sql), 'SILENT');
                if ($sqlerror = $db->error()) {
                    break;
                } else {
                    $affected_rows += intval($db->affected_rows());
                }
            }
        }
        adminlog(lang('run_sql_code'));
        amessage('sqlresult', '?entry=database&action=dbsql', $affected_rows);
    }
} elseif ($action == 'download' && $filename) {
开发者ID:polarlight1989,项目名称:08cms,代码行数:31,代码来源:database.inc.php

示例6: DoImport

	function DoImport()
	{
		$this->CheckAdminPrivs('dbimport');
		extract($this->Post);
		extract($this->Get);
		$readerror = 0;
		$datafile = '';
		if($from == 'server') {
			$datafile = ROOT_PATH.'./'.$datafile_server;
		}
		$dbcharset = $this->DatabaseHandler->Charset;

		
		if(@$fp = fopen($datafile, 'rb')) {
			$sqldump = fgets($fp, 256);
			$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", $sqldump)));
			$dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
			if($dumpinfo['method'] == 'multivol') {
				$sqldump .= fread($fp, filesize($datafile));
			}
			fclose($fp);
		} else {
			if($autoimport) {
				clearcache();
				$this->Messager('分卷数据成功导入数据库。',null);
			} else {
				$this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。',null);
			}
		}

		if($dumpinfo['method'] == 'multivol') {
			$sqlquery = splitsql($sqldump);
			unset($sqldump);
			$supetablepredot = strpos($supe['tablepre'], '.');
			$supe['dbname'] =  $supetablepredot !== FALSE ? substr($supe['tablepre'], 0, $supetablepredot) : '';

			foreach($sqlquery as $sql) {

				$sql = syntablestruct(trim($sql), $this->DatabaseHandler->GetVersion() > '4.1', $dbcharset);

				if(substr($sql, 0, 11) == 'INSERT INTO') {
					$sqldbname = substr($sql, 12, 20);
					$dotpos = strpos($sqldbname, '.');
					if($dotpos !== FALSE) {
						if(empty($supe['dbmode'])) {
							$sql = 'INSERT INTO `'.$supe['dbname'].'`.'.substr($sql, 13 + $dotpos);
						} else {
													}
					}
				}

				if($sql != '') {
					$this->DatabaseHandler->Query($sql, 'SKIP_ERROR');
					if(($sqlerror = $this->DatabaseHandler->GetLastErrorString()) && $this->DatabaseHandler->GetLastErrorNo() != 1062) {
						die('MySQL Query Error'.$sql);
					}
				}
			}

			if($delunzip) {
				@unlink($datafile_server);
			}

			$datafile_next = preg_replace("/-($dumpinfo[volume])(\..+)$/", "-".($dumpinfo['volume'] + 1)."\\2", $datafile_server);

			if($dumpinfo['volume'] == 1) {
				$to="admin.php?mod=db&code=doimport&from=server&datafile_server=".urlencode($datafile_next)."&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : '');
				$msg='            <form method="post" action="'.$to.'">
                    <br /><br /><br />分卷数据成功导入数据库,您需要自动导入本次其它的备份吗?<br /><br /><br /><br />
                    <input type="hidden" name="FORMHASH" value="'.FORMHASH.'"> &nbsp;
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
                  </form><br />';
				$this->Messager($msg,null);
			} elseif($autoimport) {
				$this->Messager("数据文件 #{$dumpinfo['volume']} 成功导入,程序将自动继续。", "admin.php?mod=db&code=doimport&from=server&datafile_server=".urlencode($datafile_next)."&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''));
			} else {
				clearcache();
				$this->Messager('数据成功导入数据库。',null);
			}
		} elseif($dumpinfo['method'] == 'shell') {
			require './config.inc.php';
			list($dbhost, $dbport) = explode(':', $dbhost);

			$query = $this->DatabaseHandler->Query("SHOW VARIABLES LIKE 'basedir'");
			list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);

			$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
			shell_exec($mysqlbin.'mysql -h"'.$dbhost.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : '').
			'" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile);

			clearcache();
			$this->Messager('数据成功导入数据库。',null);
		} else {
			$this->Messager('数据文件非 天天团购 格式,无法导入。');
		}

	}
开发者ID:pf5512,项目名称:phpstudy,代码行数:98,代码来源:db.mod.php

示例7: DoImport

    function DoImport()
    {
        if (true !== JISHIGOU_FOUNDER) {
            $this->Messager("为安全起见,只有网站创始人才能执行数据恢复操作。", null);
        }
        $readerror = 0;
        $datafile = '';
        $from = get_param('from');
        $datafile_server = get_param('datafile_server');
        $datafile_server = dir_safe($datafile_server);
        if (false == preg_match('~^\\.\\/data\\/backup\\/db\\/([\\w\\d\\-\\_]+)\\/\\1(\\-\\d+)?\\.sql$~i', $datafile_server)) {
            $this->Messager("文件名参数传递有误,请返回重试", null);
        }
        $autoimport = get_param('autoimport');
        $supe = get_param('supe');
        $delunzip = get_param('delunzip');
        if ($from == 'server') {
            $datafile = RELATIVE_ROOT_PATH . './' . $datafile_server;
        }
        $dbcharset = $this->DatabaseHandler->Charset;
        if ($datafile && false != ($fp = @fopen($datafile, 'rb'))) {
            $sqldump = fgets($fp, 256);
            $identify = explode(',', base64_decode(preg_replace("/^# Identify:\\s*(\\w+).*/s", "\\1", $sqldump)));
            $dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
            if ($dumpinfo['method'] == 'multivol') {
                $sqldump .= @fread($fp, filesize($datafile));
            }
            fclose($fp);
        } else {
            if ($autoimport) {
                cache_clear();
                $this->Messager('分卷数据成功导入数据库。', null);
            } else {
                $this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。', null);
            }
        }
        if ($dumpinfo['method'] == 'multivol') {
            $sqlquery = splitsql($sqldump);
            unset($sqldump);
            $supetablepredot = strpos($supe['tablepre'], '.');
            $supe['dbname'] = $supetablepredot !== FALSE ? substr($supe['tablepre'], 0, $supetablepredot) : '';
            foreach ($sqlquery as $sql) {
                $sql = syntablestruct(trim($sql), $this->DatabaseHandler->GetVersion() > '4.1', $dbcharset);
                if (substr($sql, 0, 11) == 'INSERT INTO') {
                    $sqldbname = substr($sql, 12, 20);
                    $dotpos = strpos($sqldbname, '.');
                    if ($dotpos !== FALSE) {
                        if (empty($supe['dbmode'])) {
                            $sql = 'INSERT INTO `' . $supe['dbname'] . '`.' . substr($sql, 13 + $dotpos);
                        } else {
                        }
                    } else {
                        $sql = 'REPLACE INTO ' . substr($sql, 11);
                    }
                }
                if ($sql != '') {
                    $this->DatabaseHandler->Query($sql, 'SKIP_ERROR');
                    if (($sqlerror = $this->DatabaseHandler->GetLastErrorString()) && $this->DatabaseHandler->GetLastErrorNo() != 1062) {
                        die('MySQL Query Error' . $sql);
                    }
                }
            }
            if ($delunzip) {
                @unlink($datafile_server);
            }
            $datafile_next = preg_replace("/\\-({$dumpinfo['volume']})(\\.sql)\$/i", "-" . ($dumpinfo['volume'] + 1) . "\\2", $datafile_server);
            if ($dumpinfo['volume'] == 1) {
                $to = "admin.php?mod=db&code=doimport&from=server&datafile_server=" . urlencode($datafile_next) . "&autoimport=yes&importsubmit=yes" . (!empty($delunzip) ? '&delunzip=yes' : '');
                $msg = '<form method="post" action="' . $to . '">
					<input type="hidden" name="FORMHASH" value="' . FORMHASH . '"  />
                    <br /><br /><br />分卷数据成功导入数据库,您需要自动导入本次其它的备份吗?<br /><br /><br /><br />
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
                  </form><br />';
                $this->Messager($msg, null);
            } elseif ($autoimport) {
                $this->Messager("数据文件 #{$dumpinfo['volume']} 成功导入,程序将自动继续。", "admin.php?mod=db&code=doimport&from=server&datafile_server=" . urlencode($datafile_next) . "&autoimport=yes&importsubmit=yes" . (!empty($delunzip) ? '&delunzip=yes' : ''));
            } else {
                cache_clear();
                $this->Messager('数据成功导入数据库。', null);
            }
        } else {
            $this->Messager('数据文件非 JishiGou 格式,无法导入。');
        }
    }
开发者ID:YouthAndra,项目名称:huaitaoo2o,代码行数:85,代码来源:db.mod.php


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