本文整理汇总了PHP中mysqli_multi_query函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_multi_query函数的具体用法?PHP mysqli_multi_query怎么用?PHP mysqli_multi_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_multi_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute_multi
function execute_multi($link, $arr_sqls, &$error)
{
$sqls = implode(';', $arr_sqls) . ';';
if (mysqli_multi_query($link, $sqls)) {
$data = array();
$i = 0;
//计数
do {
if ($result = mysqli_store_result($link)) {
$data[$i] = mysqli_fetch_all($result);
mysqli_free_result($result);
} else {
$data[$i] = null;
}
$i++;
if (!mysqli_more_results($link)) {
break;
}
} while (mysqli_next_result($link));
if ($i == count($arr_sqls)) {
return $data;
} else {
$error = "sql语句执行失败:<br /> 数组下标为{$i}的语句:{$arr_sqls[$i]}执行错误<br /> 错误原因:" . mysqli_error($link);
return false;
}
} else {
$error = '执行失败!请检查首条语句是否正确!<br />可能的错误原因:' . mysqli_error($link);
return false;
}
}
示例2: ResistMenuLog
public function ResistMenuLog($_uid, $_log)
{
$query = "TRUNCATE TABLE UM" . $_uid . ";";
$result = $this->_db_throw_query("Users_Geo", $query);
$query = "";
$tmp = "INSERT INTO UM" . $_uid . " VALUES ( '";
for ($i = 0; $i < 7; $i++) {
for ($j = 0; $j < 3; $j++) {
if ($j == 2) {
if (strpos($_log[$this->week[$i]][$this->kind[$j]], '|') !== false) {
$div = explode('|', $_log[$this->week[$i]][$this->kind[$j]]);
$size = count($div);
for ($k = 0; $k < $size; $k++) {
$query = $query . $tmp . $div[$k] . "', '" . $this->kind[$j] . "', ( NOW() + INTERVAL " . $i . " DAY ) );";
}
break;
}
}
$query = $query . $tmp . $_log[$this->week[$i]][$this->kind[$j]] . "', '" . $this->kind[$j] . "', ( NOW() + INTERVAL " . $i . " DAY ) );";
}
}
$this->_db_select("Users_Geo");
$result = mysqli_multi_query($this->_connection, $query);
if (!$result) {
print "Quely Failed.\n" . mysqli_error($this->_connection);
return false;
}
do {
mysqli_store_result($this->_connection);
} while (mysqli_next_result($this->_connection));
return true;
}
示例3: fn_execSQL
function fn_execSQL($sql, $r = 0)
{
global $conexao;
if (mysqli_multi_query($conexao, $sql)) {
$resultado = mysqli_store_result($conexao);
if ($resultado) {
//prepara um array com os campos/colunas da consulta
$i = 0;
while ($obj = mysqli_fetch_field($resultado)) {
$arrayCampos[$i] = $obj->name;
$i++;
}
//prepara um array associativo com o resultado da consulta
$i = 0;
while ($linha = mysqli_fetch_array($resultado)) {
for ($j = 0; $j < count($arrayCampos); $j++) {
$retorno[$i][$arrayCampos[$j]] = $linha[$arrayCampos[$j]];
}
$i++;
}
mysqli_free_result($resultado);
}
//mysqli_close($conexao_geral);
if (isset($retorno)) {
return $retorno;
} else {
return null;
}
} else {
echo "<p>N�o foi poss�vel executar a seguinte instru��o SQL:</p><p><strong>{$sql}</strong></p>\n" . "<p>Erro MySQL: " . mysqli_error($conexao) . "</p>";
exit;
//mysqli_close($conexao_geral);
}
}
示例4: clone_db
function clone_db($database_name = false, $organization_id = false)
{
$qry = $this->db->query('CREATE DATABASE ' . $database_name);
if (!$qry) {
$value = array('code' => '500', 'organization_id' => $organization_id);
$json_data = json_encode($value);
redirect('http://junctiondev.cloudapp.net/appmanager/login/result_application?json=' . $json_data);
}
$this->session->set_userdata('db_name', $database_name);
$this->session->userdata('db_name');
if ($_SERVER['HTTP_HOST'] == "localhost") {
//$dbname=$database_name;
$password = "";
$username = "root";
}
if ($_SERVER['HTTP_HOST'] == "junctiondev.cloudapp.net") {
//$dbname=$database_name;
$password = "bitnami";
$username = "root";
}
if ($_SERVER['HTTP_HOST'] == "junctiontech.in") {
//$dbname=$database_name;
$password = "junction4\$";
$username = "junctwhx";
}
$connect = mysqli_connect('localhost', $username, $password, $database_name);
$db_file = file_get_contents('junctionerp.sql');
mysqli_multi_query($connect, $db_file);
do {
mysqli_store_result($connect);
} while (mysqli_more_results($connect) && mysqli_next_result($connect));
return true;
}
示例5: sqllogin
function sqllogin($host, $dbuser, $dbpass, $dbname)
{
// connectivity
//mysql connections for stacked query examples.
$con1 = mysqli_connect($host, $dbuser, $dbpass, $dbname);
$username = mysqli_real_escape_string($con1, $_POST["login_user"]);
$password = $_POST["login_password"];
// Check connection
if (mysqli_connect_errno($con1)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
@mysqli_select_db($con1, $dbname) or die("Unable to connect to the database ######: ");
}
/* execute multi query */
$sql = "SELECT * FROM users WHERE username='{$username}' and password='{$password}'";
if (@mysqli_multi_query($con1, $sql)) {
/* store first result set */
if ($result = @mysqli_store_result($con1)) {
if ($row = @mysqli_fetch_row($result)) {
if ($row[1]) {
return $row[1];
} else {
return 0;
}
}
}
}
}
示例6: executeSP
/**
* @since 08.05.2011
* Refactored for using $this::mysqli_connection instead of mysqli_init/mysqli_close
*/
public function executeSP($query, &$resultArry, $assoc = TRUE)
{
$link = $this->getMysqliConnection();
//do queries
if (mysqli_multi_query($link, $query)) {
$sqlResult = mysqli_store_result($link);
if ($result) {
//$rowsAffected = mysqli_num_rows($result);
if ($assoc) {
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$resultArry[] = $row;
}
} else {
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
$resultArry[] = $row;
}
}
mysqli_free_result($result);
unset($result);
}
if (mysqli_more_results($link)) {
while (mysqli_next_result($link)) {
$sqlResult = mysqli_use_result($link);
if ($sqlResult instanceof mysqli_result) {
mysqli_free_result($sqlResult);
}
}
}
} else {
throw new DBAdapter2Exception('Error in query: ' . mysqli_error($link));
}
}
示例7: multiQuery
public function multiQuery()
{
// file_put_contents("db-sql.log", implode(";", $this->queries) . "\n", FILE_APPEND);
$success = mysqli_multi_query($this->db, implode(";", $this->queries));
$this->clearMultiQuery();
return $success;
}
示例8: execSP
function execSP($sql)
{
$this->connMySQL();
$this->sql = $sql;
$i = 0;
$result_ = null;
if (mysqli_multi_query($this->conn, $this->sql)) {
do {
if ($this->resultado = mysqli_store_result($this->conn)) {
while ($row = mysqli_fetch_array($this->resultado)) {
$result_ = $row;
}
mysqli_free_result($this->resultado);
}
$i++;
} while (mysqli_next_result($this->conn));
mysqli_close($this->conn);
} else {
echo mysqli_error($this->conn);
$this->closeConnMySQL();
exit;
}
$this->closeConnMySQL();
return $result_;
}
示例9: multi_query
public function multi_query($sql = "")
{
$this->last_query = $sql;
$result = mysqli_multi_query($this->connection, $sql);
$this->confirm_query($result);
return $result;
}
示例10: cloneDB
function cloneDB($database_name = false)
{
$this->db->query('CREATE DATABASE ' . $database_name);
if ($_SERVER['HTTP_HOST'] == "localhost") {
//$dbname=$database_name;
$password = "";
$username = "root";
}
if ($_SERVER['HTTP_HOST'] == "junctiondev.cloudapp.net") {
//$dbname=$database_name;
$password = "bitnami";
$username = "root";
}
if ($_SERVER['HTTP_HOST'] == "junctiontech.in") {
//$dbname=$database_name;
$password = "junction4\$";
$username = "junctwhx";
}
$connect = mysqli_connect('localhost', $username, $password, $database_name);
$db_file = file_get_contents('school_mgt.sql');
mysqli_multi_query($connect, $db_file);
do {
mysqli_store_result($connect);
} while (mysqli_more_results($connect) && mysqli_next_result($connect));
}
示例11: db_query
function db_query($query)
{
while ($this->db_fetch_next_result()) {
}
if (!@mysqli_multi_query($this->link, $query)) {
$this->errnum = mysqli_errno($this->link);
$this->error = mysqli_error($this->link);
$this->error_flag = 1;
return false;
}
$this->result = mysqli_store_result($this->link);
if (!$this->result) {
$this->errnum = mysqli_errno($this->link);
$this->error = mysqli_error($this->link);
$this->error_flag = 1;
return false;
}
$this->num_fields = @mysqli_num_fields($this->result);
if ($this->num_fields) {
$this->num_rows = @mysqli_num_rows($this->result);
} else {
$this->num_rows = @mysqli_affected_rows($this->link);
$this->num_fields = 0;
}
return true;
}
示例12: task_optimize
function task_optimize($connection, $settings, $time, $table = false, $and_default = true)
{
require_once $settings['functions'] . 'function.task.log.php';
if ($table) {
$tables[] = $table;
}
if ($and_default) {
$tables[] = 'peers';
$tables[] = 'tasks';
$tables[] = 'torrents';
}
$sql = '';
foreach ($tables as $table) {
$sql .= 'CHECK TABLE `' . $settings['db_prefix'] . $table . '`;' . 'ANALYZE TABLE `' . $settings['db_prefix'] . $table . '`;' . 'REPAIR TABLE `' . $settings['db_prefix'] . $table . '`;' . 'OPTIMIZE TABLE `' . $settings['db_prefix'] . $table . '`;';
}
$result = mysqli_multi_query($connection, $sql);
if ($result) {
while (mysqli_more_results($connection)) {
mysqli_next_result($connection);
mysqli_store_result($connection);
}
}
if ($result) {
task_log($connection, $settings, 'optimize', $time);
}
return $result;
}
示例13: use_sql_string
public function use_sql_string()
{
$sql = read_file($this->sql_path);
$sql = trim($sql);
$sql = $this->db->_prep_query($sql);
$link = @mysqli_connect($this->db->hostname, $this->db->username, $this->db->password, $this->db->database);
mysqli_multi_query($link, $sql);
}
示例14: importDb
private function importDb($data)
{
$sql = file_get_contents('install.sql');
$link = mysqli_connect($data['host'], $data['user'], $data['pass'], $data['dbname']);
@mysqli_multi_query($link, $sql);
$this->response['result'] = true;
$this->deleteFolderInstall();
}
示例15: update_repeat_prop_qualifier
static function update_repeat_prop_qualifier($eid, $prop_group_id, $prop_id, $ron, $prop_qual_id)
{
$sql = sprintf("Call update_repeat_prop_qualifier(%s,%s,%s,%s,%s)", $eid, $prop_group_id, $prop_id, $ron, $prop_qual_id);
if (!mysqli_multi_query($_SESSION['mysqli_link'], $sql)) {
echo "<div style='z-index:1500'>ERROR! (UpdaterSprocsContainer:aasarek)" . mysqli_error($_SESSION['mysqli_link']) . "</div>";
}
//$result = mysqli_store_result($_SESSION['mysqli_link']); echo "store result::" .mysqli_error($_SESSION['mysqli_link']);
//mysqli_free_result($result); echo $sql;
}