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


PHP mysqli::multi_query方法代码示例

本文整理汇总了PHP中mysqli::multi_query方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::multi_query方法的具体用法?PHP mysqli::multi_query怎么用?PHP mysqli::multi_query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli的用法示例。


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

示例1: change_database_structure

 /**
  * Do NOT use in code, to be used by database_manager only!
  * @param string|array $sql query
  * @param array|null $tablenames an array of xmldb table names affected by this request.
  * @return bool true
  * @throws ddl_change_structure_exception A DDL specific exception is thrown for any errors.
  */
 public function change_database_structure($sql, $tablenames = null)
 {
     $this->get_manager();
     // Includes DDL exceptions classes ;-)
     if (is_array($sql)) {
         $sql = implode("\n;\n", $sql);
     }
     try {
         $this->query_start($sql, null, SQL_QUERY_STRUCTURE);
         $result = $this->mysqli->multi_query($sql);
         if ($result === false) {
             $this->query_end(false);
         }
         while ($this->mysqli->more_results()) {
             $result = $this->mysqli->next_result();
             if ($result === false) {
                 $this->query_end(false);
             }
         }
         $this->query_end(true);
     } catch (ddl_change_structure_exception $e) {
         while (@$this->mysqli->more_results()) {
             @$this->mysqli->next_result();
         }
         $this->reset_caches($tablenames);
         throw $e;
     }
     $this->reset_caches($tablenames);
     return true;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:37,代码来源:mysqli_native_moodle_database.php

示例2: executeMulti

 public function executeMulti($sql)
 {
     if (!$this->connection) {
         $this->open();
     }
     $ret = $this->connection->multi_query($sql);
     if (!$ret) {
         $errMsg = "Can't Execute Query:" . $sql;
         $errMsg .= "\n MySQL Message:" . $this->connection->error;
         throw new \RuntimeException($errMsg);
     }
     do {
         if ($this->connection->errno) {
             $errMsg = "Can't Execute Query:" . $sql;
             $errMsg .= "\n MySQL Message:" . $this->connection->error;
             throw new \RuntimeException($errMsg);
         }
         if ($result = $this->connection->store_result()) {
             $result->free_result();
         }
         if (!$this->connection->more_results()) {
             break;
         }
     } while ($this->connection->next_result());
     return $ret;
 }
开发者ID:aainc,项目名称:Scruit,代码行数:26,代码来源:Session.php

示例3: MultiQuery

 /**
  * Preform multiple queries on the Database
  * @param string $sql 
  * @return boolean|mysqli_result
  */
 public function MultiQuery($sql)
 {
     $rs = static::$link->multi_query($sql);
     if ($rs) {
         static::__setLastResult($rs);
     }
     static::__setResults($rs);
     return $rs;
 }
开发者ID:swiftie821,项目名称:DBConnector,代码行数:14,代码来源:connector.php

示例4: persistAuditLogs

 public static function persistAuditLogs()
 {
     if (!is_array($_SESSION['auditLog']['sql']) || count($_SESSION['auditLog']['sql']) <= 0) {
         return;
     }
     $config = $_SESSION['auditLog']['database'];
     $hostname = $config['params']['host'];
     $username = $config['params']['username'];
     $password = $config['params']['password'];
     $dbname = $config['params']['dbname'];
     // in the meantime, just use mysqli because of its multi-query support
     $mysqli = new mysqli($hostname, $username, $password, $dbname);
     /* check connection */
     $retry = 10;
     // 10 seconds to retry
     $ctr = 0;
     do {
         $err = mysqli_connect_errno();
     } while ($err && $ctr++ < $retry);
     if ($err) {
         printf("Connect failed: %s\n", mysqli_connect_error());
         return;
     }
     // generate queries
     $queries = implode(";\n", $_SESSION['auditLog']['sql']);
     /* execute multi query */
     $mysqli->multi_query($queries);
     /* close connection */
     $mysqli->close();
 }
开发者ID:psoas,项目名称:ch3-dev-preview,代码行数:30,代码来源:App.php

示例5: create_tables

 public function create_tables($data)
 {
     // Connect to the database
     $mysqli = new mysqli($data['db_hostname'], $data['db_username'], $data['db_password'], $data['db_database']);
     // Check for errors
     if (mysqli_connect_errno()) {
         return false;
     }
     // Open the default SQL file
     $query = file_get_contents('assets/install.sql');
     $pw = $this->password($data['admin_password']);
     $handled_enc = $this->handle_enc_pms($data);
     $new = str_replace("%ENCRYPT_PRIVATE_MESSAGES%", $data['encrypt_private_messages'], $query);
     $new = str_replace("%ALLOW_GUESTS%", $data['allow_guests'], $new);
     $new = str_replace("%FORCE_VENDOR_PGP%", $data['force_vendor_pgp'], $new);
     $new = str_replace("%ELECTRUM_MPK%", $data['electrum_mpk'], $new);
     $new = str_replace("%PASSWORD%", $pw['hash'], $new);
     $new = str_replace("%PUBLIC_KEY%", $handled_enc['public_key'], $new);
     $new = str_replace("%PRIVATE_KEY%", $handled_enc['private_key'], $new);
     $new = str_replace("%PRIVATE_KEY_SALT%", $handled_enc['private_key_salt'], $new);
     $new = str_replace("%REGISTER_TIME%", time(), $new);
     $new = str_replace("%USER_HASH%", substr(hash('sha512', mcrypt_create_iv(32, MCRYPT_DEV_URANDOM)), 0, 16), $new);
     $new = str_replace("%SALT%", $pw['salt'], $new);
     // Execute a multi query
     $mysqli->multi_query($new);
     if (mysqli_connect_errno()) {
         var_dump($mysqli);
         return false;
     }
     // Close the connection
     $mysqli->close();
     return true;
 }
开发者ID:marketcoinfork,项目名称:BitWasp-Fork,代码行数:33,代码来源:database_class.php

示例6: InitializeData

 function InitializeData()
 {
     $this->TruncateTables();
     $r = $this->Connection->multi_query($this->GetDataSQL());
     while ($this->Connection->more_results()) {
         $this->Connection->next_result();
     }
 }
开发者ID:michalkoczwara,项目名称:WebGoatPHP,代码行数:8,代码来源:mysqli.php

示例7: multiQuery

 /**
  * Performs multiple SQL queries. Results are flushed and not returned. Useful for multiple updates and inserts.
  *
  * @param string $multiSql semicolon separated queries to be sent to the DB
  *
  * @return void
  * @throws \iveeCore\Exceptions\SQLErrorException when the query execution errors out
  */
 public function multiQuery($multiSql)
 {
     $startTime = microtime(true);
     if (!$this->db->multi_query($multiSql)) {
         $exceptionClass = Config::getIveeClassName('SQLErrorException');
         throw new $exceptionClass($this->db->error . "\nQuery: " . $multiSql, $this->db->errno);
     }
     //gather stats about queries
     $this->addQueryTime(microtime(true) - $startTime);
     $this->flushDbResults();
 }
开发者ID:Covert-Inferno,项目名称:iveeCore,代码行数:19,代码来源:SDE.php

示例8: makeInstallation

function makeInstallation($s)
{
    if ($s['createDb']) {
        /* create BDD */
        $mysqli = new mysqli($s['db_adress'], $s['db_user'], $s['db_password']);
        /* check connection */
        if ($mysqli->connect_errno) {
            printf("Connect failed: %s\n", $mysqli->connect_error);
            exit(24);
        }
        $q = "CREATE DATABASE IF NOT EXISTS `" . $s['db_schema'] . "` /*!40100 DEFAULT CHARACTER SET utf8 */;";
        //echo "Création BDD ::".$q;
        //exit;
        if (!$mysqli->query($q)) {
            echo "Création BDD impossible";
            exit;
        }
        $mysqli->close();
    }
    $mysqli = new mysqli($s['db_adress'], $s['db_user'], $s['db_password'], $s['db_schema']);
    /* execute multi query */
    $mysqli->multi_query(file_get_contents('install/install.sql'));
    while ($mysqli->next_result()) {
    }
    // flush multi_queries
    /* init de la table des dates de reference */
    $start_day = mktime(0, 0, 0, 9, 1, 2014);
    //1er septembre 2014
    $stop_day = mktime(0, 0, 0, 9, 1, 2037);
    //justqu'au 1er septembre 2037, on verra en 2037 si j'utilise encore l'app.
    $nb_day = ($stop_day - $start_day) / 86400;
    $query = "INSERT INTO oko_dateref (jour) VALUES ";
    for ($i = 0; $i <= $nb_day; $i++) {
        $day = date('Y-m-d', mktime(0, 0, 0, date("m", $start_day), date("d", $start_day) + $i, date("Y", $start_day)));
        $query .= "('" . $day . "'),";
    }
    $query = substr($query, 0, strlen($query) - 1) . ";";
    //print_r($query);exit;
    $mysqli->query($query);
    $mysqli->close();
    /* Make Config.php */
    $configFile = file_get_contents('config_sample.php');
    $configFile = str_replace("###_BDD_IP_###", $s['db_adress'], $configFile);
    $configFile = str_replace("###_BDD_USER_###", $s['db_user'], $configFile);
    $configFile = str_replace("###_BDD_PASS_###", $s['db_password'], $configFile);
    $configFile = str_replace("###_BDD_SCHEMA_###", $s['db_schema'], $configFile);
    $configFile = str_replace("###_CONTEXT_###", getcwd(), $configFile);
    $configFile = str_replace("###_TOKEN_###", sha1(rand()), $configFile);
    //$configFile = str_replace("###_TOKEN-API_###",sha1(rand()),$configFile);
    file_put_contents('config.php', $configFile);
    /* Make config.json */
    $param = array("chaudiere" => $s['oko_ip'], "tc_ref" => $s['param_tcref'], "poids_pellet" => $s['param_poids_pellet'], "surface_maison" => $s['surface_maison'], "get_data_from_chaudiere" => $s['oko_typeconnect'], "send_to_web" => "0");
    file_put_contents('config.json', json_encode($param));
}
开发者ID:stawen,项目名称:okovision,代码行数:54,代码来源:setup.php

示例9: multi_query

 /**
  * @param string $query
  * @return bool|null
  */
 public function multi_query($query)
 {
     $result = parent::multi_query($query);
     if ($this->errno) {
         $error = $this->error;
         $this->rollback();
         $this->ThrowQueryError($query, $error);
         return null;
     } else {
         return $result;
     }
 }
开发者ID:Riges,项目名称:KawaiViewModel,代码行数:16,代码来源:MySQL.php

示例10: ExecuteMultiQuery

 /**
  * Executes a multi query string; typically concatenated by semicolon
  * @param sring $query
  * @throws DBExceptions\DatabaseException Raises an exception in case of an error
  */
 public function ExecuteMultiQuery($query)
 {
     $result = $this->db->multi_query($query);
     if ($result) {
         while ($this->db->next_result()) {
         }
         //overgo the results!
     }
     if (!$result) {
         throw new DBExceptions\DatabaseException('Error in multi query', 101, $query);
     }
 }
开发者ID:agentmedia,项目名称:phine-framework,代码行数:17,代码来源:Connection.php

示例11: getSQLResultSet

function getSQLResultSet($commando)
{
    $mysqli = new mysqli("localhost", "root", "12345", "conexionandroid");
    $mysqli->query("SET NAMES 'utf8'");
    if ($mysqli->connect_error) {
        printf("Connect failed: %s\n", $mysqli->connect_error);
        exit;
    }
    if ($mysqli->multi_query($commando)) {
        return $mysqli->store_result();
    }
    $mysqli->close();
}
开发者ID:KellyA1D5J,项目名称:Otros,代码行数:13,代码来源:functions.php

示例12: query

 /**
  * @param $query
  * @return bool|mysqli_result
  */
 public function query($query)
 {
     if ($res = $this->link->multi_query($query)) {
         do {
             if ($res = mysqli_store_result($this->link)) {
                 mysqli_free_result($res);
             }
             if (mysqli_more_results($this->link)) {
             }
         } while (mysqli_next_result($this->link));
     }
     return $res;
 }
开发者ID:enderteszla,项目名称:phpframework-etc,代码行数:17,代码来源:DB.php

示例13: xquery

 /**
  * 发送批量查询语句
  * 记作一次查询,只返回最后的查询结果
  */
 public function xquery($sql, $noerror = false)
 {
     $this->result = $this->conn->multi_query($sql);
     $this->queryCount++;
     if (!$this->result) {
         if ($noerror == true) {
             return false;
         } else {
             throw new Exception("MySQL 批量语句执行错误:<br/><b>语句:</b>{$sql}<br/><b>错误:</b>" . $this->geterror(), 10000);
         }
     } else {
         return $this->result;
     }
 }
开发者ID:wan-qy,项目名称:Tieba-Cloud-Sign,代码行数:18,代码来源:class.mysqli.php

示例14: init

 public function init()
 {
     $this->load->helper(array('form', 'file', 'url'));
     $this->load->library(array('form_validation'));
     $cartPath = dirname(FCPATH);
     $testConfig = is_writeable($cartPath . '/application/config/');
     $testUploads = is_writeable($cartPath . '/uploads/');
     $testIntl = class_exists('Locale');
     $errors = !$testConfig ? '<div class="alert alert-danger" role="alert">The folder "' . $cartPath . '/application/config" must be writable.</div>' : '';
     $errors .= !$testUploads ? '<div class="alert alert-danger" role="alert">The folder "' . $cartPath . '/uploads" must be writable.</div>' : '';
     $errors .= !$testIntl ? '<div class="alert alert-danger" role="alert">The PHP_INTL Library is required for GoCart and is not installed on your server. <a href="http://php.net/manual/en/book.intl.php">Read More</a></div>' : '';
     $this->form_validation->set_rules('hostname', 'Hostname', 'required');
     $this->form_validation->set_rules('database', 'Database Name', 'required');
     $this->form_validation->set_rules('username', 'Username', 'required');
     $this->form_validation->set_rules('password', 'Password', 'trim|required');
     $this->form_validation->set_rules('prefix', 'Database Prefix', 'trim');
     if ($this->form_validation->run() == FALSE || $errors != '') {
         $this->form_validation->set_error_delimiters('<div class="alert alert-danger">', '</div>');
         $errors .= validation_errors();
         $this->load->view('index', ['errors' => $errors]);
     } else {
         $dbCred = $this->input->post();
         //test the database
         mysqli_report(MYSQLI_REPORT_STRICT);
         try {
             $db = new mysqli($dbCred['hostname'], $dbCred['username'], $dbCred['password'], $dbCred['database']);
         } catch (Exception $e) {
             $errors = '<div class="alert alert-danger" role="alert">There was an error connecting to the database</div>';
             $this->load->view('index', ['errors' => $errors]);
             return;
         }
         //create the database file
         $database = $this->load->view('database', $this->input->post(), true);
         $myfile = fopen($cartPath . '/application/config/database.php', "w");
         fwrite($myfile, $database);
         fclose($myfile);
         $sql = str_replace('gc_', $dbCred['prefix'], file_get_contents(FCPATH . 'database.sql'));
         $db->multi_query($sql);
         // run the dump
         while ($db->more_results() && $db->next_result()) {
         }
         //run through it
         //set some basic information in settings
         $query = "INSERT INTO `{$dbCred['prefix']}settings` (`code`, `setting_key`, `setting`) VALUES\n\t\t\t('gocart', 'theme', 'default'),\n\t\t\t('gocart', 'locale', 'en_US'),\n\t\t\t('gocart', 'currency_iso', 'USD'),\n\t\t\t('gocart', 'new_customer_status', '1'),\n\t\t\t('gocart', 'order_statuses', '{\"Order Placed\":\"Order Placed\",\"Pending\":\"Pending\",\"Processing\":\"Processing\",\"Shipped\":\"Shipped\",\"On Hold\":\"On Hold\",\"Cancelled\":\"Cancelled\",\"Delivered\":\"Delivered\"}'),\n\t\t\t('gocart', 'products_per_page', '24'),\n\t\t\t('gocart', 'default_meta_description', 'Thanks for installing GoCart.'),\n\t\t\t('gocart', 'default_meta_keywords', 'open source, ecommerce'),\n\t\t\t('gocart', 'timezone', 'UTC');";
         $db->query($query);
         $db->close();
         $url = dirname((isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '/admin';
         header('Location: ' . dirname($url) . '/admin');
     }
 }
开发者ID:thijmenvenus,项目名称:GoCart3,代码行数:50,代码来源:Installer.php

示例15: addUserData

 function addUserData($userName, $firstName, $lastName, $staffId, $designation, $email_Id, $phoneNumber)
 {
     $sql = "INSERT INTO `nicdata`(`userName`, `firstName`, `lastName`, `staffId`, `designation`, `email_Id`,`phoneNumber`) ";
     $sql .= "VALUES ('" . $userName . "','" . $firstName . "','" . $lastName . "','" . $staffId . "','" . $designation . "','" . $email_Id . "','" . $phoneNumber . "')";
     echo $sql;
     $conn = new mysqli(constant("SERVER_NAME_NIC"), constant("DB_USER_NIC"), constant("DB_PASSWORD_NIC"), constant("DB_NAME_NIC"));
     if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
     }
     if ($conn->multi_query($sql) === true) {
         $result = "Success";
     }
     $conn->close();
 }
开发者ID:nagyist,项目名称:Samarthya,代码行数:14,代码来源:dal.nicportal.php


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