當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysqli_multi_query函數代碼示例

本文整理匯總了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 />&nbsp;數組下標為{$i}的語句:{$arr_sqls[$i]}執行錯誤<br />&nbsp;錯誤原因:" . mysqli_error($link);
            return false;
        }
    } else {
        $error = '執行失敗!請檢查首條語句是否正確!<br />可能的錯誤原因:' . mysqli_error($link);
        return false;
    }
}
開發者ID:sakuraliu,項目名稱:bbs,代碼行數:30,代碼來源:mysql.inc.php

示例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;
 }
開發者ID:Reciplan,項目名稱:Web,代碼行數:32,代碼來源:liblog.php

示例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);
    }
}
開發者ID:iaraujoisraell,項目名稱:Educacional,代碼行數:34,代碼來源:conexao.php

示例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;
 }
開發者ID:junctiontech,項目名稱:careermitra,代碼行數:33,代碼來源:User_management_model.php

示例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;
                }
            }
        }
    }
}
開發者ID:intfrr,項目名稱:sqli-labs,代碼行數:28,代碼來源:login.php

示例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));
     }
 }
開發者ID:sergrin,項目名稱:crawlers-il,代碼行數:36,代碼來源:DBAdapter2.class.php

示例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;
 }
開發者ID:Alkyoneus,項目名稱:Froxlor,代碼行數:7,代碼來源:DB.mysqli.class.php

示例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_;
 }
開發者ID:kevinMoreira,項目名稱:Lab,代碼行數:25,代碼來源:MySQL.php

示例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;
 }
開發者ID:sureshr-gnts,項目名稱:sf-w,代碼行數:7,代碼來源:class.database.php

示例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));
 }
開發者ID:junctiontech,項目名稱:appmanager,代碼行數:25,代碼來源:restAPI_model.php

示例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;
 }
開發者ID:pranav6487,項目名稱:pet_project,代碼行數:26,代碼來源:database.class.mysqli.inc.php

示例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;
}
開發者ID:dogsAreReallyCool,項目名稱:phoenix,代碼行數:27,代碼來源:function.task.optimize.php

示例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);
 }
開發者ID:Intelnetgs,項目名稱:white,代碼行數:8,代碼來源:install_m.php

示例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();
 }
開發者ID:alexber127,項目名稱:StCms-v3.0,代碼行數:8,代碼來源:installCheck.php

示例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;
 }
開發者ID:awgtek,項目名稱:myedb,代碼行數:9,代碼來源:UpdaterSprocsContainer.php


注:本文中的mysqli_multi_query函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。