当前位置: 首页>>代码示例>>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;未经允许,请勿转载。