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


PHP mysqli::escape_string方法代碼示例

本文整理匯總了PHP中mysqli::escape_string方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysqli::escape_string方法的具體用法?PHP mysqli::escape_string怎麽用?PHP mysqli::escape_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mysqli的用法示例。


在下文中一共展示了mysqli::escape_string方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updatePlayer

 public function updatePlayer(IPlayer $player, $lastIP = null, $loginDate = null)
 {
     $name = trim(strtolower($player->getName()));
     if ($lastIP !== null) {
         $this->database->query("UPDATE simpleauth_players SET lastip = '" . $this->database->escape_string($lastIP) . "' WHERE name = '" . $this->database->escape_string($name) . "'");
     }
     if ($loginDate !== null) {
         $this->database->query("UPDATE simpleauth_players SET logindate = " . intval($loginDate) . " WHERE name = '" . $this->database->escape_string($name) . "'");
     }
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:10,代碼來源:MySQLDataProvider.php

示例2: getStats

 public function getStats($playerName)
 {
     $playerName = $this->db->escape_string(trim(strtolower($playerName)));
     $result = $this->db->query("SELECT * FROM tntstats WHERE name = '" . $playerName . "'");
     if ($result instanceof \mysqli_result) {
         $assoc = $result->fetch_assoc();
         $result->free();
         if (isset($assoc["name"]) and $assoc["name"] === $playerName) {
             return $assoc;
         }
     }
     return null;
 }
開發者ID:EmreTr1,項目名稱:TNTRun,代碼行數:13,代碼來源:MySQLStatsProvider.php

示例3: quote

 /**
  * Экранирует значение
  * @param  string|array $value
  * @param  null         $type
  * @return string
  */
 public function quote($value, $type = null)
 {
     if (is_array($value)) {
         foreach ($value as $key => $val) {
             $q = $this->getQuoteIdentifierSymbol();
             $value[$key] = $q . $this->db->escape_string($value) . $q;
         }
         $quoted_value = implode(', ', $value);
     } else {
         $q = $this->getQuoteIdentifierSymbol();
         $quoted_value = $q . $this->db->escape_string($value) . $q;
     }
     return $quoted_value;
 }
開發者ID:shabuninil,項目名稱:combine,代碼行數:20,代碼來源:Mysqli.php

示例4: escStr

 public function escStr($str)
 {
     if (is_bool($str)) {
         return $str ? "1" : "0";
     }
     return is_string($str) ? "'{$this->mysqli->escape_string($str)}'" : "{$str}";
 }
開發者ID:LegionPE,項目名稱:LegionPE-Eta,代碼行數:7,代碼來源:MysqlConnection.php

示例5: escape

 /**
  * escaping a string
  * 
  * @param string $str
  * @return string
  */
 public function escape($str)
 {
     if (!$this->ready()) {
         return false;
     }
     return $this->_MySQLi->escape_string($str);
 }
開發者ID:gpuenteallott,項目名稱:rox,代碼行數:13,代碼來源:db_mysqli.lib.php

示例6: onPlayerQuit

 /**
  * @param PlayerQuitEvent $e
  */
 public function onPlayerQuit(PlayerQuitEvent $e)
 {
     if ($this->getPlayer($e->getPlayer()) == null) {
         $this->AddPlayer($e->getPlayer());
     } else {
         $this->db->query("UPDATE player_stats SET quits = quits +1 WHERE name = '" . $this->db->escape_string($e->getPlayer()->getName()) . "'") or die($this->bd->mysqli_error());
     }
     //$this->db->query("UPDATE player_stats SET quits = quits +1 WHERE name = '".$this->db->escape_string($e->getPlayer()->getName())."'") or die($this->bd->mysqli_error());
 }
開發者ID:AndreyNazarchuk,項目名稱:PlayerStats,代碼行數:12,代碼來源:PlayerStats.php

示例7: escape_string

 /**
  * Escape a string to be used in a SQL query.
  *
  * @param String $string The string to escape
  *
  * @return Mixed $return The escaped string on success, FALSE on error
  */
 public function escape_string($string)
 {
     $this->connect();
     if ($this->connected === TRUE) {
         return $this->mysqli->escape_string($string);
     } else {
         return FALSE;
     }
 }
開發者ID:rubendgr,項目名稱:lunr,代碼行數:16,代碼來源:MySQLConnection.php

示例8: escapeMethod

 /**
  * Escaped einen String, der durch Nutzereingabe herkommt
  * 
  * @param type $string
  * @return type $string
  * @author Halldor Rolandsson
  */
 public function escapeMethod($string)
 {
     $database = new mysqli($this->dbHost, $this->dbUser, $this->dbPass, $this->dbDatabase);
     if (mysqli_connect_errno()) {
         printf("Connect failed: %s\n", mysqli_connect_error());
         exit;
     }
     $string = $database->escape_string($string);
     $database->close();
     return $string;
 }
開發者ID:pestKater,項目名稱:wiki-wiki-legacy,代碼行數:18,代碼來源:databaseClass.php

示例9: _process_values

 protected function _process_values($values)
 {
     $data = array();
     foreach ($values as $v) {
         if (is_string($v)) {
             $v = $this->_connection->escape_string($v);
         }
         $data[] = $v;
     }
     return $data;
 }
開發者ID:ravikathaitarm01,項目名稱:fluenz1,代碼行數:11,代碼來源:MySqli.php

示例10: touchIP

 public function touchIP($ip)
 {
     //		$ip = $this->db->escape_string(implode("", array_map(function($token){
     //			return chr(intval($token));
     //		}, explode(".", $ip))));
     $ip = $this->db->escape_string($ip);
     $result = $this->db->query("SELECT ip FROM {$this->itn} WHERE ip = '{$ip}';");
     $exists = is_array($result->fetch_assoc());
     $result->close();
     if (!$exists) {
         $this->db->query("INSERT INTO {$this->itn} VALUES ('{$ip}');");
     }
     return $exists;
 }
開發者ID:MCPEGamerJPatGitHub,項目名稱:xEcon,代碼行數:14,代碼來源:MysqliDataProvider.php

示例11: getDataPart

 /**
  * Creates a new SQL-part for this field.
  * (Only adds ' around string typed fields)
  */
 private final function getDataPart($data, $type)
 {
     $ret = "";
     switch ($type) {
         case 'number':
             $ret = $data;
             break;
         case 'string':
             $ret = "'" . $this->db->escape_string($data) . "'";
             break;
         default:
             $ret = "'" . $this->db->escape_string($data) . "'";
     }
     return $ret;
 }
開發者ID:netzbandit,項目名稱:YAMPF,代碼行數:19,代碼來源:model.class.php

示例12: checkForeignKeys

/**
 * Checks a MySQL database for invalid foreign keys, i.e., a keys pointing to missing rows.
 *
 * @author     David Grudl (http://davidgrudl.com)
 * @copyright  Copyright (c) 2008 David Grudl
 * @license    New BSD License
 * @version    1.0
 */
function checkForeignKeys(mysqli $db, $database = NULL)
{
    $keys = $db->query('
		SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
		FROM information_schema.KEY_COLUMN_USAGE
		WHERE REFERENCED_TABLE_SCHEMA IS NOT NULL' . ($database ? " AND TABLE_SCHEMA='{$db->escape_string($database)}'" : ''));
    foreach ($keys as $key) {
        echo "{$key['TABLE_SCHEMA']} {$key['TABLE_NAME']}.{$key['COLUMN_NAME']}: ";
        foreach ($key as &$identifier) {
            $identifier = '`' . str_replace('`', '``', $identifier) . '`';
        }
        $row = $db->query("\n\t\t\tSELECT COUNT({$key['COLUMN_NAME']})\n\t\t\tFROM {$key['TABLE_SCHEMA']}.{$key['TABLE_NAME']}\n\t\t\tWHERE {$key['COLUMN_NAME']} NOT IN (SELECT {$key['REFERENCED_COLUMN_NAME']} FROM {$key['TABLE_SCHEMA']}.{$key['REFERENCED_TABLE_NAME']})\n\t\t")->fetch_array();
        echo $row[0] ? "found {$row['0']} invalid foreign keys!\n" : "OK\n";
    }
}
開發者ID:dg,項目名稱:mysql-check,代碼行數:23,代碼來源:checkForeignKeys.php

示例13: cleanCriteria

 private function cleanCriteria($criteria)
 {
     if (is_numeric($criteria)) {
         if (false !== strpos($criteria, '.')) {
             $criteria = floatval($criteria);
         } else {
             $criteria = intval($criteria);
         }
     } elseif (is_array($criteria)) {
         $criteria = json_encode($criteria);
     } elseif (is_string($criteria)) {
         $criteria = $this->db->escape_string($criteria);
     }
     return $criteria;
 }
開發者ID:aleksandarzivanovic,項目名稱:vibe,代碼行數:15,代碼來源:StorageMySqlQueryBuilder.php

示例14: die

             $stmt->execute() or die($stmt->error);
             $tabAdresseId[$rep->idadresse] = array('rue', $mysqliNew->insert_id);
         } else {
             echo '<p>aucun quartier correspondant à ' . $nomQuartier . '</p>';
             $tabAdresseId[$rep->idadresse] = array('erreur', $mysqliNew->insert_id);
         }
     } else {
         if (!empty($rep->nomville)) {
             $nomVille = nettoyeChaine($rep->nomville);
             $stmtTrouveIdVille->execute() or die($stmt->error);
             $stmtTrouveIdVille->bind_result($idVille);
             if ($stmtTrouveIdVille->fetch()) {
                 $stmtTrouveIdVille->free_result();
                 $result = $mysqliNew->query('SELECT idSousQuartier FROM sousQuartier sq WHERE idQuartier=(SELECT idQuartier FROM quartier sq WHERE idVille=' . $idVille . ' AND nom="autre") AND nom="autre"');
                 $reponse = $result->fetch_object();
                 $nom = $mysqliNew->escape_string($nom);
                 $prefixe = $mysqliNew->escape_string($prefixe);
                 // ajout laurent : pour separation prefixe (complement) du nom de la rue
                 $idSousQuartier = $reponse->idSousQuartier;
                 $stmt->execute() or die($stmt->error);
                 $tabAdresseId[$rep->idadresse] = array('rue', $mysqliNew->insert_id);
             } else {
                 echo '<p>aucun quartier correspondant à ' . $nomQuartier . '</p>';
                 $tabAdresseId[$rep->idadresse] = array('erreur', $mysqliNew->insert_id);
             }
         } else {
             echo '<p>PERTE : idadresse = ' . $rep->idadresse . '</p>';
             $tabAdresseId[$rep->idadresse] = array('erreur', $mysqliNew->insert_id);
         }
     }
 }
開發者ID:archi-strasbourg,項目名稱:archi-wiki,代碼行數:31,代碼來源:importArchiV1.php

示例15: mysqli

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $db = new mysqli('localhost', 'root', '', 'hospital');
    // Prepare data for insertion
    $id = $db->escape_string($_POST["id"]);
    $soort = $db->escape_string($_POST["soort"]);
    // Prepare query and execute
    $query = "insert into species (id, soort) values ('{$id}','{$soort}')";
    $result = $db->query($query);
    // Tell the browser to go back to the index page.
    header("Location: ./");
    exit;
}
開發者ID:GJ-Ligthart,項目名稱:hospital,代碼行數:14,代碼來源:create.logic.php


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