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


PHP mysqli::more_results方法代码示例

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


在下文中一共展示了mysqli::more_results方法的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: Call_Procedure

 /**
  * Rabota s khranimy`mi protcedurami i funktciiami.
  *
  * Vy`polnenie khranimy`kh protcedur i funktcii` cherez metod peregruzki metodov
  *
  * @param string $store_procedure_name imia khranimoi` protcedury`
  * @param array $params spisok parametrov khranimoi` protcedury`
  * @return array rezul`tat
  */
 public static function Call_Procedure($store_procedure_name, $params = [])
 {
     $quotedparams = [];
     foreach ($params as $param) {
         array_push($quotedparams, $param === null ? 'NULL' : "'" . self::$DB->real_escape_string($param) . "'");
     }
     $sql = 'CALL ' . $store_procedure_name . '(' . implode(',', $quotedparams) . ');';
     /* execute multi query */
     if (!self::Query_Real($sql)) {
         return false;
     }
     $results = [];
     do {
         if (false != ($result = self::$DB->use_result())) {
             $rows = [];
             while (false != ($row = $result->fetch_assoc())) {
                 $rows[] = $row;
             }
             $result->close();
             $results[] = $rows;
         }
     } while (self::$DB->more_results() && self::$DB->next_result());
     if (1 < count($results)) {
         return $results;
     } else {
         if (1 < count($results[0])) {
             return $results[0];
         } else {
             if (1 < count($results[0][0])) {
                 return $results[0][0];
             }
         }
     }
     return array_shift($results[0][0]);
 }
开发者ID:kshamiev,项目名称:testXml,代码行数:44,代码来源:DB.php

示例4: _dynamicBindResults

 /**
  * This helper method takes care of prepared statements' "bind_result method
  * , when the number of variables to pass is unknown.
  *
  * @param mysqli_stmt $stmt Equal to the prepared statement object.
  *
  * @return array The results of the SQL fetch.
  */
 protected function _dynamicBindResults(mysqli_stmt $stmt)
 {
     $parameters = array();
     $results = array();
     // See http://php.net/manual/en/mysqli-result.fetch-fields.php
     $mysqlLongType = 252;
     $shouldStoreResult = false;
     $meta = $stmt->result_metadata();
     // if $meta is false yet sqlstate is true, there's no sql error but the query is
     // most likely an update/insert/delete which doesn't produce any results
     if (!$meta && $stmt->sqlstate) {
         return array();
     }
     $row = array();
     while ($field = $meta->fetch_field()) {
         if ($field->type == $mysqlLongType) {
             $shouldStoreResult = true;
         }
         $row[$field->name] = null;
         $parameters[] =& $row[$field->name];
     }
     // avoid out of memory bug in php 5.2 and 5.3. Mysqli allocates lot of memory for long*
     // and blob* types. So to avoid out of memory issues store_result is used
     // https://github.com/joshcam/PHP-MySQLi-Database-Class/pull/119
     if ($shouldStoreResult) {
         $stmt->store_result();
     }
     call_user_func_array(array($stmt, 'bind_result'), $parameters);
     $this->totalCount = 0;
     $this->count = 0;
     while ($stmt->fetch()) {
         if ($this->returnType == 'Object') {
             $x = new stdClass();
             foreach ($row as $key => $val) {
                 $x->{$key} = $val;
             }
         } else {
             $x = array();
             foreach ($row as $key => $val) {
                 $x[$key] = $val;
             }
         }
         $this->count++;
         array_push($results, $x);
     }
     // stored procedures sometimes can return more then 1 resultset
     if ($this->_mysqli->more_results()) {
         $this->_mysqli->next_result();
     }
     if (in_array('SQL_CALC_FOUND_ROWS', $this->_queryOptions)) {
         $stmt = $this->_mysqli->query('SELECT FOUND_ROWS()');
         $totalCount = $stmt->fetch_row();
         $this->totalCount = $totalCount[0];
     }
     if ($this->returnType == 'Json') {
         return json_encode($results);
     }
     return $results;
 }
开发者ID:blakester06,项目名称:PHP-MySQLi-Database-Class,代码行数:67,代码来源:MysqliDb.php

示例5: 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

示例6: import_sql

 /**
  * imports a sql file via mysqli
  *
  * @param  string $sql
  *
  * @return int  Number of Sql queries made, -1 if error
  */
 public function import_sql($sql)
 {
     //connect via mysqli for easier db import
     $mysqli = new \mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     // Run the SQL
     $i = 1;
     if ($mysqli->multi_query($sql)) {
         do {
             if ($mysqli->more_results()) {
                 $mysqli->next_result();
                 $i++;
             }
         } while ($mysqli->more_results());
     }
     if ($mysqli->errno) {
         return -1;
     }
     mysqli_close($mysqli);
     return $i;
 }
开发者ID:ahiliation,项目名称:beautifulwork,代码行数:27,代码来源:Importer.php

示例7: multi_query_result

 /**
  * @desc Get only multi query result
  *
  * @access public
  * @return mixed
  */
 public function multi_query_result()
 {
     $data = array();
     do {
         if ($this->result = $this->link->store_result()) {
             $data[] = $this->result->fetch_all($this->fetchMode);
             $this->result->free();
         }
     } while ($this->link->more_results() && $this->link->next_result());
     return $data;
 }
开发者ID:emrahsifoglu,项目名称:simple-news-portal,代码行数:17,代码来源:MySQLiDriver.php

示例8: import_sql

 /**
  * imports a sql file via mysqli
  *
  * @param  string   $sql
  * @param \WP_Error $error
  *
  * @return int  Number of Sql queries made, -1 if error
  */
 public function import_sql($sql, $error)
 {
     //connect via mysqli for easier db import
     $mysqli = new \mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     // Run the SQL
     $i = 1;
     if ($mysqli->multi_query($sql)) {
         do {
             if ($mysqli->more_results()) {
                 $mysqli->next_result();
                 $i++;
             }
         } while ($mysqli->more_results());
     }
     if ($mysqli->errno) {
         $error->add('sql_import_error', __('<b>Mysqli Error:</b> ' . $mysqli->error, 'search-and-replace'));
         return -1;
     }
     mysqli_close($mysqli);
     return $i;
 }
开发者ID:s-hinse,项目名称:search-and-replace,代码行数:29,代码来源:DatabaseImporter.php

示例9: 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

示例10: createDB

 /**
  * Create new databases.
  */
 protected static function createDB()
 {
     // Setup DB
     $m = new \mysqli(ini_get('mysqli.default_host'), ini_get('mysqli.default_user') ?: 'root', ini_get('mysqli.default_pw'));
     if ($m->connect_error) {
         throw new \PHPUnit_Framework_SkippedTestError("Failed to connect to mysql: " . $m->connect_error);
     }
     $sql = file_get_contents(__DIR__ . '/../../support/db.sql');
     if (!$m->multi_query($sql)) {
         throw new \PHPUnit_Framework_SkippedTestError("Failed to initialise DBs: " . $m->error);
     }
     // Make sure everything is executed
     do {
         $m->use_result();
     } while ($m->more_results() && $m->next_result());
     self::$reuse_db = true;
 }
开发者ID:sachsy,项目名称:DB-MySQL,代码行数:20,代码来源:DBTest.php

示例11: execute_query

function execute_query($mysqli, $query)
{
    $bcloseconnection = false;
    // did we get passed a valid connection (i.e. did the calling function already make the connection to the db for us?)
    if (!isset($mysqli)) {
        //echo '<br>execute_query: opening db connection';
        $bcloseconnection = true;
        // Connect to the database
        $mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
        // check connection
        if (mysqli_connect_errno()) {
            log_error(sprintf("sql_execute: Connect failed: %s\n", mysqli_connect_error()));
            return false;
        }
    }
    //echo '<br>query='.$query;
    // execute the query
    if ($mysqli->multi_query($query)) {
        // Setup an incrementing count of the result set;
        $result_set_id = 0;
        do {
            if ($result = $mysqli->store_result()) {
                $ary_results[$result_set_id] = $result;
                // Increment the result set
                $result_set_id++;
            }
        } while ($mysqli->more_results() && $mysqli->next_result());
        // need to check if we got any resultsets back into the array...if not, the query was probably still valid so return TRUE
        if (!is_array($ary_results)) {
            return true;
        }
    } else {
        echo $mysqli->error;
        //log_error(sprintf("sql_execute: the query '%s' failed to execute due to the following error: '%s'", $query, $mysqli->error));
        return false;
    }
    // if we had to open the connection, then close it
    if ($bcloseconnection) {
        //echo '<br>execute_query: closing db connection';
        $mysqli->close();
    }
    return $ary_results;
}
开发者ID:YonasBerhe,项目名称:LS,代码行数:43,代码来源:utils.inc.php

示例12: _dynamicBindResults

 /**
  * This helper method takes care of prepared statements' "bind_result method
  * , when the number of variables to pass is unknown.
  *
  * @param mysqli_stmt $stmt Equal to the prepared statement object.
  *
  * @return array The results of the SQL fetch.
  */
 protected function _dynamicBindResults(mysqli_stmt $stmt)
 {
     $parameters = array();
     $results = array();
     $meta = $stmt->result_metadata();
     // if $meta is false yet sqlstate is true, there's no sql error but the query is
     // most likely an update/insert/delete which doesn't produce any results
     if (!$meta && $stmt->sqlstate) {
         return array();
     }
     $row = array();
     while ($field = $meta->fetch_field()) {
         $row[$field->name] = null;
         $parameters[] =& $row[$field->name];
     }
     // avoid out of memory bug in php 5.2 and 5.3
     // https://github.com/joshcam/PHP-MySQLi-Database-Class/pull/119
     if (version_compare(phpversion(), '5.4', '<')) {
         $stmt->store_result();
     }
     call_user_func_array(array($stmt, 'bind_result'), $parameters);
     $this->totalCount = 0;
     $this->count = 0;
     while ($stmt->fetch()) {
         $x = array();
         foreach ($row as $key => $val) {
             $x[$key] = $val;
         }
         $this->count++;
         array_push($results, $x);
     }
     // stored procedures sometimes can return more then 1 resultset
     if ($this->_mysqli->more_results()) {
         $this->_mysqli->next_result();
     }
     if (in_array('SQL_CALC_FOUND_ROWS', $this->_queryOptions)) {
         $stmt = $this->_mysqli->query('SELECT FOUND_ROWS()');
         $totalCount = $stmt->fetch_row();
         $this->totalCount = $totalCount[0];
     }
     return $results;
 }
开发者ID:rostrowicki,项目名称:PHP-MySQLi-Database-Class,代码行数:50,代码来源:MysqliDb.php

示例13: queryMulti

 /**
  * Executes multiple queries given in one string within a single request.
  *
  * @param  string $sql The string with the multiple queries.
  * @return boolean false if the first statement failed. Otherwise true.
  */
 public function queryMulti($sql)
 {
     $result = false;
     $sql = $this->getSqlWithPrefix($sql);
     /*
      * Executing the multiple queries.
      */
     if ($this->conn->multi_query($sql)) {
         while ($this->conn->more_results()) {
             /*
              * If more results are available from the multi_query call we go
              * to the next result and free its memory usage.
              */
             $this->conn->next_result();
             $result = $this->conn->store_result();
             if ($result) {
                 $result->free();
             }
         }
     }
     return $result;
 }
开发者ID:prepare4battle,项目名称:Ilch-2.0,代码行数:28,代码来源:Mysql.php

示例14: multi_query

 public function multi_query($resource)
 {
     $Timer = microtime(true);
     if (parent::multi_query($resource)) {
         do {
             if ($result = parent::store_result()) {
                 $result->free();
             }
             $this->queryCount++;
             if (!parent::more_results()) {
                 break;
             }
         } while (parent::next_result());
     }
     $this->SQL[] = $resource;
     if ($this->errno) {
         if ($this->exception == true) {
             throw new Exception("SQL Error: " . $this->error . "<br><br>Query Code: " . $resource);
         } else {
             return "SQL Error: " . $this->error;
         }
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:23,代码来源:class.MySQLi.php

示例15: __runQuery

 /** 
  * Run a query on a database object, returning the result
  *
  * @param mysqli $databaseObj A database object to run the query on.
  * @param string $query The query to run.
  * @return mixed An array of results if query is successful, or null on error.
  */
 private function __runQuery($databaseObj, $query)
 {
     $results = array();
     if ($databaseObj->multi_query($query)) {
         do {
             if ($result = $databaseObj->store_result()) {
                 array_push($results, $result->fetch_all(MYSQLI_ASSOC));
                 $result->free();
             }
             if (!$databaseObj->more_results()) {
                 break;
             }
             $databaseObj->next_result();
         } while (true);
         // If we only ran one query and got one result
         // just return that
         if (count($results) == 1) {
             return $results[0];
         }
         return $results;
     } else {
         if ($databaseObj->error) {
             $this->__logMessage(sprintf('Error: Query - %s failed with message - %s', $query, $databaseObj->error));
         }
     }
     return null;
 }
开发者ID:JodiWarren,项目名称:hms,代码行数:34,代码来源:Setup.php


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