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


PHP mysqli_real_query函数代码示例

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


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

示例1: delete

 function delete($tabloAdi, $kosul)
 {
     $sql = "DELETE FROM " . $tabloAdi . " WHERE " . $kosul;
     if (!mysqli_real_query($this->baglantiNo, $sql)) {
         throw new DBException("Silme sorgusunda sorun var...");
     }
 }
开发者ID:GULSENCIMEN,项目名称:projeler,代码行数:7,代码来源:ClassVeritabaniMysqli.php

示例2: execute_bool

function execute_bool($link, $query)
{
    $bool = mysqli_real_query($link, $query);
    if (mysqli_errno($link)) {
        exit(mysqli_error($link));
    }
    return $bool;
}
开发者ID:sakuraliu,项目名称:bbs,代码行数:8,代码来源:mysql.inc.php

示例3: mysql_unbuffered_query

 function mysql_unbuffered_query($query, \mysqli $link = null)
 {
     $link = \Dshafik\MySQL::getConnection($link);
     if (mysqli_real_query($link, $query)) {
         return mysqli_use_result($link);
     }
     return false;
 }
开发者ID:muhammedalialat,项目名称:php7-mysql-shim,代码行数:8,代码来源:mysql.php

示例4: istable

function istable($table)
{
    global $mysqli;
    mysqli_real_query($mysqli, "SELECT 1 FROM `{$table}` LIMIT 1 ");
    mysqli_use_result($mysqli);
    if (mysqli_errno($mysqli) == 1146) {
        return false;
    } else {
        return true;
    }
}
开发者ID:KunalT6569,项目名称:opinion-mining,代码行数:11,代码来源:mfunctions.php

示例5: mysqli_query_select_varchar_unbuffered

function mysqli_query_select_varchar_unbuffered($type, $len, $runs, $rows, $host, $user, $passwd, $db, $port, $socket, $flag_original_code)
{
    $errors = $times = array();
    foreach ($rows as $k => $num_rows) {
        foreach ($runs as $k => $run) {
            $times[$num_rows . ' rows: SELECT ' . $type . ' ' . $run . 'x overall'] = microtime(true);
            do {
                if (!($link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
                    $errors[] = sprintf("%d rows: SELECT %s %dx connect failure (original code = %s)", $num_rows, $type, $run, $flag_original_code ? 'yes' : 'no');
                    break 3;
                }
                if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
                    $errors[] = sprintf("%d rows: SELECT %s %dx drop table failure (original code = %s): [%d] %s", $num_rows, $type, $run, $flag_original_code ? 'yes' : 'no', mysqli_errno($link), mysqli_error($link));
                    break 3;
                }
                if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label %s)", $type))) {
                    $errors[] = sprintf("%d rows: SELECT %s %dx create table failure (original code = %s): [%d] %s", $num_rows, $type, $run, $flag_original_code ? 'yes' : 'no', mysqli_errno($link), mysqli_error($link));
                    break 3;
                }
                $label = '';
                for ($i = 0; $i < $len; $i++) {
                    $label .= chr(mt_rand(65, 90));
                }
                $label = mysqli_real_escape_string($link, $label);
                for ($i = 1; $i <= $num_rows; $i++) {
                    if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ({$i}, '{$label}')")) {
                        $errors[] = sprintf("%d rows: SELECT %s %dx insert failure (original code = %s): [%d] %s", $num_rows, $type, $run, $flag_original_code ? 'yes' : 'no', mysqli_errno($link), mysqli_error($link));
                        break 3;
                    }
                }
                for ($i = 0; $i < $run; $i++) {
                    $start = microtime(true);
                    mysqli_real_query($link, "SELECT id, label FROM test");
                    $res = mysqli_use_result($link);
                    $times[$num_rows . ' rows: SELECT ' . $type . ' ' . $run . 'x query()'] += microtime(true) - $start;
                    if (!$res) {
                        $errors[] = sprintf("%d rows: SELECT %s %dx insert failure (original code = %s): [%d] %s", $rows, $type, $run, $flag_original_code ? 'yes' : 'no', mysqli_errno($link), mysqli_error($link));
                        break 4;
                    }
                    $start = microtime(true);
                    while ($row = mysqli_fetch_assoc($res)) {
                    }
                    $times[$num_rows . ' rows: SELECT ' . $type . ' ' . $run . 'x fetch_assoc()'] += microtime(true) - $start;
                }
                mysqli_close($link);
            } while (false);
            $times[$num_rows . ' rows: SELECT ' . $type . ' ' . $run . 'x overall'] = microtime(true) - $times[$num_rows . ' rows: SELECT ' . $type . ' ' . $run . 'x overall'];
        }
    }
    return array($errors, $times);
}
开发者ID:splitice,项目名称:mysqlnd_ms,代码行数:51,代码来源:mysqli_sel_unbuf.php

示例6: __construct

 public function __construct($cfg)
 {
     $link = @mysqli_connect($cfg['dbserver'], $cfg['dbuser'], $cfg['dbpass'], $cfg['dbname']);
     if ($link) {
         $this->linkid = $link;
         $this->connected = true;
         if (!empty($cfg['dbcharset'])) {
             mysqli_real_query($link, "SET NAMES '{$cfg['dbcharset']}'");
         }
     } else {
         $this->errnum = mysqli_connect_errno();
         $this->error = mysqli_connect_error();
     }
 }
开发者ID:CatBerg-TestOrg,项目名称:coppermine,代码行数:14,代码来源:dbase.inc.php

示例7: query

 function query($query)
 {
     $args = array();
     if (is_array($query)) {
         $args = $query;
         // only use arg 1
     } else {
         $args = func_get_args();
     }
     $query = $this->_format_query($args);
     $this->querycount++;
     if (isset($this->get['debug'])) {
         $this->debug($query);
     }
     mysqli_real_query($this->connection, $query) or error(QUICKSILVER_QUERY_ERROR, mysqli_error($this->connection), $query, mysqli_errno($this->connection));
     return mysqli_store_result($this->connection);
 }
开发者ID:BackupTheBerlios,项目名称:qsf-svn,代码行数:17,代码来源:mysqli.php

示例8: executeMultiNoresSQL

 /**
  * Transaction style - runs queries in order
  *
  * @since 08.05.2011
  * Refactored for using $this::mysqli_connection instead of mysqli_init/mysqli_close
  */
 public function executeMultiNoresSQL(&$queryArry)
 {
     $link = $this->getMysqliConnection();
     /* set autocommit to off */
     mysqli_autocommit($link, FALSE);
     $all_query_ok = true;
     //do queries
     foreach ($queryArry as $query) {
         if (!mysqli_real_query($link, $query)) {
             $all_query_ok = false;
         }
     }
     if ($all_query_ok) {
         /* commit queries */
         mysqli_commit($link);
     } else {
         /* Rollback */
         mysqli_rollback($link);
     }
     /* set autocommit to on */
     mysqli_autocommit($link, TRUE);
     return $all_query_ok;
 }
开发者ID:sergrin,项目名称:crawlers-il,代码行数:29,代码来源:DBAdapter2.class.php

示例9: executeMultiNoresSQL

 public function executeMultiNoresSQL(&$queryArry)
 {
     $link = mysqli_init();
     if (!$link) {
         throw new DBAdapter2Exception("mysqli_init failed");
     }
     if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
         throw new DBAdapter2Exception("Setting MYSQLI_OPT_CONNECT_TIMEOUT failed");
     }
     if (!mysqli_real_connect($link, $this->host, $this->username, $this->password, $this->schema)) {
         throw new DBAdapter2Exception('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
     }
     if (!mysqli_set_charset($link, $this->charset)) {
         throw new DBAdapter2Exception('Error loading character set ' . $this->charset . ' - ' . mysqli_error($link));
     }
     /* set autocommit to off */
     mysqli_autocommit($link, FALSE);
     $all_query_ok = true;
     //do queries
     foreach ($queryArry as $query) {
         if (!mysqli_real_query($link, $query)) {
             $all_query_ok = false;
         }
     }
     if ($all_query_ok) {
         /* commit queries */
         mysqli_commit($link);
     } else {
         /* Rollback */
         mysqli_rollback($link);
     }
     /* set autocommit to on */
     mysqli_autocommit($link, TRUE);
     mysqli_close($link);
     return $all_query_ok;
 }
开发者ID:sergrin,项目名称:crawlers-il,代码行数:36,代码来源:DBAdapter2.class.php

示例10: str_replace

            $amount = str_replace(',', '.', $_POST['amount']);
        } else {
            exit('Fehler: Kosten');
        }
    } else {
        $amount = $_POST['amount'];
    }
    $query = 'UPDATE
                  costs_person
                SET
                  costs_person.year = \'' . $_POST['year'] . '\',
                  costs_person.usage = \'' . $post_usage . '\',
                  costs_person.amount = \'' . $amount . '\'
                WHERE
                  costs_person.id = ' . $_GET['param'];
    $result = mysqli_real_query($db, $query);
}
$query_costs = 'SELECT
                      costs_person.year, costs_person.usage, costs_person.amount
                    FROM
                      costs_person
                    WHERE costs_person.id =' . $_GET['param'];
$result_costs = mysqli_query($db, $query_costs);
mysqli_close($db);
echo '<body';
if ($result) {
    echo ' onload="window.opener.location.href=\'costs_person.php\'; window.close();"';
}
echo '>';
echo '<div class="head">
            <h1>Kosten pro Person ändern</h1>
开发者ID:Hoernchen20,项目名称:service-charges,代码行数:31,代码来源:costs_person_change.php

示例11: excel

	margin-bottom: 3em;
}
.left {
	
}
.right {
	width: 60%;
}
</style>
<h1>Ents Bookings</h1>
<p> Download in <a href="bookings_Spreadsheet.php">spreadsheet format</a>. This is a tab separated file. In order to import it into excel (or similar software) correctly, make sure the 'tab' box is the only box checked for the delimiters (comma, space, etc should be unchecked).</p>
<table>
<?php 
$cv = mysqli_connect("localhost", "mayball_admin", "XuthebAw97");
mysqli_select_db($cv, "mayball");
mysqli_real_query($cv, "SELECT ents_slots.*,ents.* FROM ents INNER JOIN ents_slots ON ents.ents_slot_id=ents_slots.ents_slot_id ORDER BY ents_slots.time;");
if ($result = mysqli_use_result($cv)) {
    while (($row = mysqli_fetch_assoc($result)) != null) {
        echo "<tr>";
        echo "<td class='left'>" . date("D jS M - g:i a", strtotime($row["time"])) . "</td>";
        echo "<td class='right'>";
        echo "<span class='label'>Act Name</span>: " . $row["act_name"] . "<br />";
        echo "<span class='label'>Act Type</span>: " . $row["act_type"] . "<br />";
        echo "<span class='label'>Genre/Description</span>: <div id='genre'>" . nl2br($row["genre"]) . "</div><br />";
        echo "<span class='label'>Contact</span>: <a href='mailto:'" . $row["contact_email"] . "'>" . $row["contact_name"] . "</a> [" . $row["contact_phone"] . "] <br />";
        echo "</td>";
        echo "</tr>";
    }
}
mysqli_free_result($result);
?>
开发者ID:JJMinton,项目名称:2014JesusMayBall_frontpage,代码行数:31,代码来源:viewBookings.php

示例12: printf

<?php

require_once "connect.inc";
$tmp = NULL;
$link = NULL;
$test_table_name = 'test_mysqli_use_result_table_1';
require 'table.inc';
if (!($res = mysqli_real_query($link, "SELECT id, label FROM test_mysqli_use_result_table_1 ORDER BY id"))) {
    printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!is_object($res = mysqli_use_result($link))) {
    printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link));
}
if (false !== ($tmp = mysqli_data_seek($res, 2))) {
    printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
}
mysqli_free_result($res);
if (!mysqli_query($link, "DELETE FROM test_mysqli_use_result_table_1")) {
    printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (false !== ($res = mysqli_use_result($link))) {
    printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link));
}
if (!($res = mysqli_query($link, "SELECT id, label FROM test_mysqli_use_result_table_1 ORDER BY id"))) {
    printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (false !== ($tmp = mysqli_data_seek($res, 1))) {
    printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
}
mysqli_close($link);
if (NULL !== ($tmp = mysqli_use_result($link))) {
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:mysqli_use_result.php

示例13: phorum_db_interact

/**
 * This function is the central function for handling database interaction.
 * The function can be used for setting up a database connection, for running
 * a SQL query and for returning query rows. Which of these actions the
 * function will handle and what the function return data will be, is
 * determined by the $return function parameter.
 *
 * @param $return   - What to return. Options are the following constants:
 *                    DB_RETURN_CONN      a db connection handle
 *                    DB_RETURN_QUOTED    a quoted parameter
 *                    DB_RETURN_RES       result resource handle
 *                    DB_RETURN_ROW       single row as array
 *                    DB_RETURN_ROWS      all rows as arrays
 *                    DB_RETURN_ASSOC     single row as associative array
 *                    DB_RETURN_ASSOCS    all rows as associative arrays
 *                    DB_RETURN_VALUE     single row, single column
 *                    DB_RETURN_ROWCOUNT  number of selected rows
 *                    DB_RETURN_NEWID     new row id for insert query
 *                    DB_RETURN_ERROR     an error message if the query
 *                                        failed or NULL if there was no error
 *                    DB_CLOSE_CONN       close the connection, no return data
 *
 * @param $sql      - The SQL query to run or the parameter to quote if
 *                    DB_RETURN_QUOTED is used.
 *
 * @param $keyfield - When returning an array of rows, the indexes are
 *                    numerical by default (0, 1, 2, etc.). However, if
 *                    the $keyfield parameter is set, then from each
 *                    row the $keyfield index is taken as the key for the
 *                    return array. This way, you can create a direct
 *                    mapping between some id field and its row in the
 *                    return data. Mind that there is no error checking
 *                    at all, so you have to make sure that you provide
 *                    a valid $keyfield here!
 *
 * @param $flags    - Special flags for modifying the function's behavior.
 *                    These flags can be OR'ed if multiple flags are needed.
 *                    DB_NOCONNECTOK     Failure to connect is not fatal but
 *                                       lets the call return FALSE (useful
 *                                       in combination with DB_RETURN_CONN).
 *                    DB_MISSINGTABLEOK  Missing table errors not fatal.
 *                    DB_DUPFIELDNAMEOK  Duplicate field errors not fatal.
 *                    DB_DUPKEYNAMEOK    Duplicate key name errors not fatal.
 *                    DB_DUPKEYOK        Duplicate key errors not fatal.
 *
 * @return $res     - The result of the query, based on the $return parameter.
 */
function phorum_db_interact($return, $sql = NULL, $keyfield = NULL, $flags = 0)
{
    static $conn;
    // Close the database connection.
    if ($return == DB_CLOSE_CONN) {
        if (!empty($conn)) {
            mysqli_close($conn);
            $conn = null;
        }
        return;
    }
    // Setup a database connection if no database connection is available yet.
    if (empty($conn)) {
        $PHORUM = $GLOBALS['PHORUM'];
        $conn = mysqli_connect($PHORUM['DBCONFIG']['server'], $PHORUM['DBCONFIG']['user'], $PHORUM['DBCONFIG']['password'], $PHORUM['DBCONFIG']['name'], $PHORUM['DBCONFIG']['port'], $PHORUM['DBCONFIG']['socket']);
        if ($conn === FALSE) {
            if ($flags & DB_NOCONNECTOK) {
                return FALSE;
            }
            phorum_database_error('Failed to connect to the database.');
            exit;
        }
        if (!empty($PHORUM['DBCONFIG']['charset'])) {
            mysqli_query($conn, "SET NAMES '{$PHORUM['DBCONFIG']['charset']}'");
        }
        // putting this here for testing mainly
        // All of Phorum should work in strict mode
        if (!empty($PHORUM["DBCONFIG"]["strict_mode"])) {
            mysqli_query($conn, "SET SESSION sql_mode='STRICT_ALL_TABLES'");
        }
    }
    // Return a quoted parameter.
    if ($return === DB_RETURN_QUOTED) {
        return mysqli_real_escape_string($conn, $sql);
    }
    // RETURN: database connection handle
    if ($return === DB_RETURN_CONN) {
        return $conn;
    }
    // By now, we really need a SQL query.
    if ($sql === NULL) {
        trigger_error('Internal error: phorum_db_interact(): ' . 'missing sql query statement!', E_USER_ERROR);
    }
    // Execute the SQL query.
    // For queries where we are going to retrieve multiple rows, we
    // use an unuffered query result.
    if ($return === DB_RETURN_ASSOCS || $return === DB_RETURN_ROWS) {
        $res = FALSE;
        if (mysqli_real_query($conn, $sql) !== FALSE) {
            $res = mysqli_use_result($conn);
        }
    } else {
        $res = mysqli_query($conn, $sql);
//.........这里部分代码省略.........
开发者ID:sheldon,项目名称:dejavu,代码行数:101,代码来源:mysqli.php

示例14: db_write

/**
 * @param $sql
 * @param $paras
 * @return bool|string
 */
function db_write($sql, $paras)
{
    if (dbconfig_w::Provider == "mysqli") {
        //mysqli的情况
        if (extension_loaded("mysqli")) {
            $con = mysqli_connect(dbconfig_w::DataSource, dbconfig_w::UserID, dbconfig_w::Password, dbconfig_w::InitialCatalog, dbconfig_w::Port);
            if ($con != false) {
                if ($paras == null) {
                    $rel = mysqli_real_query($con, $sql);
                    $data = false;
                    if ($rel != false) {
                        $data = $rel;
                    } else {
                        $data = dberror::SQL_EXCEPTION;
                    }
                } else {
                    $mt = $con->stmt_init();
                    $mt->prepare($sql);
                    foreach ($paras as $para) {
                        $val = $para->value;
                        mysqli_stmt_bind_param($mt, $para->type, $val);
                    }
                    unset($para);
                    $rel = mysqli_stmt_execute($mt);
                    if ($rel != false) {
                        $data = $rel;
                    } else {
                        return dberror::SQL_EXCEPTION;
                    }
                }
                mysqli_close($con);
                return $data;
            } else {
                return dberror::CONNECT_EXCEPTION;
            }
        } else {
            return dberror::NO_MYSQLI_EXCEPTION;
        }
    } else {
        //mysql的情况
        if (extension_loaded("mysql")) {
            $con = mysql_connect(dbconfig_w::DataSource, dbconfig_w::UserID, dbconfig_w::Password, dbconfig_w::InitialCatalog, dbconfig_w::Port);
            if ($con != false) {
                if ($paras == null) {
                    $rel = mysql_query($con, $sql);
                    $data = false;
                    if ($rel != false) {
                        $data = true;
                    } else {
                        $data = dberror::SQL_EXCEPTION;
                    }
                } else {
                    $data = dberror::MYSQL_NO_PREPARE_EXCEPTION;
                }
                mysql_close($con);
                return $data;
            } else {
                return dberror::CONNECT_EXCEPTION;
            }
        } else {
            return dberror::NO_MYSQL_EXCEPTION;
        }
    }
}
开发者ID:Takeya-Yuki-Studio,项目名称:Yuki-Auth-Login,代码行数:69,代码来源:dbconnect.php

示例15: excel

	margin-bottom: 3em;
}
.left {
	
}
.right {
	width: 60%;
}
</style>
<h1>Non-Auditioning Ents</h1>
<p> Download in <a href="nonAudition_Spreadsheet.php">spreadsheet format</a>. This is a tab separated file. In order to import it into excel (or similar software) correctly, make sure the 'tab' box is the only box checked for the delimiters (comma, space, etc should be unchecked).</p>
<table>
<?php 
$cv = mysqli_connect("localhost", "mayball_admin", "XuthebAw97");
mysqli_select_db($cv, "mayball");
mysqli_real_query($cv, "SELECT * FROM ents WHERE ents_slot_id=0;");
if ($result = mysqli_use_result($cv)) {
    while (($row = mysqli_fetch_assoc($result)) != null) {
        echo "<tr>";
        echo "<td class='right'>";
        echo "<span class='label'>Act Name</span>: " . $row["act_name"] . "<br />";
        echo "<span class='label'>Act Type</span>: " . $row["act_type"] . "<br />";
        echo "<span class='label'>Genre/Description</span>: <div id='genre'>" . nl2br($row["genre"]) . "</div><br />";
        echo "<span class='label'>Website</span>: <div id='genre'>" . nl2br($row["website"]) . "</div><br />";
        echo "<span class='label'>Performance Location</span>: <div id='genre'>" . nl2br($row["performance_location"]) . "</div><br />";
        echo "<span class='label'>Contact</span>: <a href='mailto:'" . $row["contact_email"] . "'>" . $row["contact_name"] . "</a> [" . $row["contact_phone"] . "] <br />";
        echo "</td>";
        echo "</tr>";
    }
}
mysqli_free_result($result);
开发者ID:JJMinton,项目名称:2014JesusMayBall_frontpage,代码行数:31,代码来源:viewNonAudition.php


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