本文整理汇总了PHP中mysqli::real_query方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::real_query方法的具体用法?PHP mysqli::real_query怎么用?PHP mysqli::real_query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::real_query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Query_Real
/**
* Vy`polnenie zaprosa i vozvrashchenie deskriptora na rezul`tat
*
* Dlia khranimy`kh protcedur
* - Zamer vremeni vy`polneniia zaprosa
* - V sluchae oshibki vozvrashchaet false
* - Zapis` zaprosa i vremeni ego vy`polneniia v fai`l-loge
*
* @param string $sql zapros k BD
* @return bool|mysqli_result
* @throws Exception
*/
protected static function Query_Real($sql)
{
Zero_Logs::Info('#{SQL} ' . $sql);
$res = self::$DB->real_query($sql);
if (!$res) {
Zero_Logs::Error('#{SQL ERROR} ' . self::$DB->error);
Zero_Logs::Error('#{SQL} ' . $sql);
throw new Exception(self::$DB->error, 500);
}
return $res;
}
示例2: execute
public function execute($sql, array $parameters = null)
{
$this->initConnection();
if ($parameters) {
$sql = $this->escapeSql($sql, $parameters);
}
$this->log($sql);
if (!$this->mysql->real_query($sql)) {
$this->checkDbError($sql);
}
}
示例3: insert
public function insert($sql)
{
$this->errorCode = 0;
$this->lastSql = $sql;
if (!$this->MySqli->real_query($sql)) {
$this->error('insert');
}
$this->numRows = $this->MySqli->affected_rows;
return $this;
//For chaining and PONIES!!!
}
示例4: real_query
/**
* @param string $query
* @return bool|null
*/
public function real_query($query)
{
$result = parent::real_query($query);
if ($this->errno) {
$error = $this->error;
$this->rollback();
$this->ThrowQueryError($query, $error);
return null;
} else {
return $result;
}
}
示例5: __construct
/**
Initialises a mysql prepared statement.
@param $oDb The mysql link resource.
@param $sQuery The query.
*/
public function __construct(weeDatabase $oDb, mysqli $oMySQLi, $sQuery)
{
preg_match_all('/:([\\w_]+)/', $sQuery, $aMatches, PREG_OFFSET_CAPTURE);
$s = '';
$iOffset = 0;
foreach ($aMatches[1] as $aMatch) {
$this->aParametersMap[] = $aMatch[0];
$s .= substr($sQuery, $iOffset, $aMatch[1] - $iOffset - 1) . '?';
$iOffset = $aMatch[1] + strlen($aMatch[0]);
}
$s .= substr($sQuery, $iOffset);
$this->sStatementName = 'st_' . md5($sQuery);
$this->oDb = $oDb;
$this->oMySQLi = $oMySQLi;
$s = 'PREPARE ' . $this->sStatementName . ' FROM ' . $this->oDb->escape($s);
$oMySQLi->real_query($s) or burn('DatabaseException', sprintf(_WT("Failed to prepare the query with the following error:\n%s"), $oMySQLi->error));
}
示例6: test
public function test(Request $request)
{
$db = new \mysqli('localhost', 'root', 'root', 'ryan');
$count = 10;
/*
$category_map = array('/shop/art-design-books'=>'6','/shop/backpacks'=>'3','/shop/bags'=>'3','/shop/bar'=>'5','/shop/blocks'=>'8','/shop/books'=>'6','/shop/camping'=>'7','/shop/candles'=>'5','/shop/clocks'=>'5','/shop/coffee-&-tea'=>'5','/shop/cycling'=>'7','/shop/everyday-carry'=>'1','/shop/fragrance'=>'2','/shop/furniture'=>'5','/shop/gadgets'=>'4','/shop/garden'=>'5','/shop/handbags'=>'9','/shop/headphones'=>'4','/shop/home'=>'5','/shop/kitchen'=>'5','/shop/kitchen-knives'=>'5','/shop/knit-hats'=>'3','/shop/lighting'=>'5','/shop/mens-apparel'=>'10','/shop/men-s-shoes'=>'10','/shop/mugs'=>'5','/shop/office'=>'1','/shop/personal-care'=>'1','/shop/photography'=>'4','/shop/photography-books'=>'6','/shop/picnic'=>'5','/shop/pocket-knives'=>'7','/shop/socks'=>'3','/shop/speakers'=>'4','/shop/stationery'=>'1','/shop/storage-&-organization'=>'5','/shop/sunglasses'=>'3','/shop/toys-&-things'=>'8','/shop/watches'=>'3','/shop/water-bottles'=>'1','/shop/womens-apparel'=>'9','/shop/womens-shoes'=>'9');
foreach($category_map as $from_where => $to_where)
{
$db->query("UPDATE `canopy_item_list` SET `to_where`='{$to_where}' WHERE `from_where`='{$from_where}'");
}
dd($category_map);
*/
for ($i = 1; $i < 11; $i++) {
$results = $db->query("SELECT * FROM `canopy_item_list` WHERE `title`<>'' AND `price`<>'' AND `image_data`<>'' AND `to_where` = {$i} AND `sent_at` IS NULL ORDER BY `id` ASC LIMIT 0,{$count}");
while ($row = $results->fetch_assoc()) {
$this->post->storeCurated($row, $i);
$db->real_query("UPDATE `canopy_item_list` SET `sent_at` = CURRENT_TIMESTAMP WHERE id={$row['id']}");
}
}
$db->close();
}
示例7: mysqli
<?php
//LOGOWANIE TaWuA8kf
$haslo = $_GET['password'];
$login = $_GET['name'];
$servername = "db.zut.edu.pl";
$dbname = "gg36296";
$username = "gg36296";
$password = "TaWuA8kf";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
$sql = "SELECT name,password FROM accountdata WHERE name LIKE '{$login}' AND password LIKE '{$haslo}' ";
$conn->real_query($sql);
$res = $conn->use_result();
while ($row = $res->fetch_assoc()) {
if ($login == $row['name'] && $haslo == $row['password']) {
echo "xD";
} else {
echo "login or password is incorrect";
}
}
}
示例8: mysqli
<?php
$IP = "localhost";
$USER = "root";
$PASS = "root";
$BD = "shop";
$mysqli = new mysqli($IP, $USER, $PASS, $BD);
if ($mysqli->connect_errno) {
echo "Falló la conexión con MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$mysqli->real_query("SELECT * FROM books");
$resultado = $mysqli->use_result();
while ($fila = $resultado->fetch_assoc()) {
echo "Id = " . $fila['book_id'] . "<br>";
echo "Titulo = " . $fila['title'] . "<br>";
echo "Autor = " . $fila['author'] . "<br>";
echo "Precio = " . $fila['price'] . "<br>";
echo "<br>";
}
示例9: callMySQLIProcedure
function callMySQLIProcedure($sql)
{
$mysqli = new mysqli(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS, XOOPS_DB_NAME);
$mysqli->real_query($sql);
$result = $mysqli->store_result();
$row = $result->fetch_assoc();
$status = $row['status'];
$mysqli->close();
return $status;
}
示例10: json_encode
<?php
$mysqli = new mysqli("localhost", "daohang", "e02b2943b3c6265b12da8f385f7cab75", "daohang");
/* check connection */
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
//printf("Current character set: %s\n", $mysqli->character_set_name());
}
$mysqli->real_query("select *from xinwenkeji order by id asc");
$res = $mysqli->use_result();
$items = array();
while ($row = $res->fetch_assoc()) {
//print_r($row);
array_push($items, $row);
}
echo json_encode($items);
//echo $_GET['query'];
示例11: query
/**
* Выполнение SQL запроса.
*
* Если запрос вернет несколько наборов результатов(multi query)
* будет обработан только первый. Все остальные будут проигнорированы,
* а соединение с базой данных будет доступно для следующих запросов.
*
* Данный метод реккомендуется использовать для выполнения
* хранимых продцедур, которые возвращают один набор результатов.
* Второй набор результатов OK/ERR будет автоматически проигнорирован.
*
* @throws DBException в случае возникновения ошибки в запросе
* @param string $query SQL запрос
* @param int $flags флаги для обработки результатов доступны следующие флаги: {@link DB::USE_RESULT DB::USE_RESULT}, {@link DB::STORE_RESULT},
* {@link DB::FETCH_NUM DB::FETCH_NUM }, {@link DB::FETCH_ASSOC DB::FETCH_ASSOC }, {@link DB::FETCH_BOTH DB::FETCH_BOTH };
* @return mixed массив результатов; affected_rows в случает успешного "UPDATE"-одобного запроса; lastInsertedId в случае insert запроса.
*/
public static function query($query, $flags = null)
{
//print_pre('==============================mysql:<b>'.$query.'</b>' );
$r = self::$mysqli->real_query($query);
if ($r === true) {
// process flags
$data_process = 'mysqli_store_result';
if ($flags & DB::USE_RESULT) {
$data_process = 'mysqli_use_result';
}
//var_dump($data_process);
$resulttype = MYSQLI_ASSOC;
if ($flags & DB::FETCH_NUM) {
$resulttype = MYSQLI_NUM;
} else {
if ($flags & DB::FETCH_BOTH) {
$resulttype = MYSQLI_BOTH;
}
}
$res = call_user_func($data_process, self::$mysqli);
if (is_object($res)) {
$data = array();
while (($d = $res->fetch_array($resulttype)) !== null) {
$data[] = $d;
}
} else {
if (strcmp(strtolower(substr(ltrim($query), 6)), 'insert')) {
$data = self::$mysqli->insert_id;
} else {
$data = self::$mysqli->affected_rows;
}
}
self::clearResultset($res);
return $data;
} else {
throw new DBException(self::$mysqli->error, self::$mysqli->errno, $query);
}
}
示例12: getDBSize
public static function getDBSize($dbname, mysqli $mysqli)
{
$sql = "SELECT\n\t\t\tTABLE_SCHEMA AS db_name,\n\t\t\tCONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),' MB') AS data_size,\n\t\t\tCONCAT(TRUNCATE(SUM(index_length)/1024/1024,2),'MB') AS index_size\n\t\tFROM information_schema.tables WHERE TABLE_SCHEMA='{$dbname}'\n\t\tGROUP BY TABLE_SCHEMA\n\t\tORDER BY data_length DESC";
if (!$mysqli->real_query($sql)) {
if (self::$verbose) {
echo 'getDBSize failed:' . $mysqli->error . "\n";
}
return false;
}
$result = $mysqli->store_result();
if ($row = $result->fetch_assoc()) {
return $row;
}
if (self::$verbose) {
echo "Schema {$dbname} not exist\n";
}
return false;
}
示例13: realQuery
/**
* Execute an SQL query.
*
* Wrapper around [mysqli::real_query](http://php.net/manual/en/mysqli.real-query.php), however on failure an
* exception is thrown.
*
* @param string $query The SQL statement.
*/
protected static function realQuery($query)
{
if (self::$logQueries) {
$time0 = microtime(true);
$ret = self::$mysqli->real_query($query);
if ($ret === false) {
throw new DataLayerException(self::$mysqli->errno, self::$mysqli->error, $query);
}
self::$queryLog[] = ['query' => $query, 'time' => microtime(true) - $time0];
} else {
$ret = self::$mysqli->real_query($query);
if ($ret === false) {
throw new DataLayerException(self::$mysqli->errno, self::$mysqli->error, $query);
}
}
}
示例14: mysqli
<?php
$mysqli = new mysqli("localhost", "daohang", "e02b2943b3c6265b12da8f385f7cab75", "daohang");
/* check connection */
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
//printf("Current character set: %s\n", $mysqli->character_set_name());
}
$mysqli->real_query("SELECT * FROM xinwenyule ORDER BY id ASC");
$res = $mysqli->use_result();
//echo "Result set order...\n";
while ($row = $res->fetch_assoc()) {
echo $row['title'] . $row['author'] . $row['link'] . '\\n';
echo '<a href="' . $row['link'] . '" target="_blank">' . $row['title'] . ' by ' . $row['author'] . '</a>';
}
示例15: setUp
public function setUp()
{
if (!self::$mysql->real_query("TRUNCATE TABLE " . self::$DB_TABLE_NAME)) {
throw new \Exception("Could not truncate table");
}
}