本文整理汇总了PHP中MySQLi::escape_string方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLi::escape_string方法的具体用法?PHP MySQLi::escape_string怎么用?PHP MySQLi::escape_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLi
的用法示例。
在下文中一共展示了MySQLi::escape_string方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create a new annotation
*
* @param Struct\Annotation $annotation
* @return void
*/
public function create(Struct\Annotation $annotation)
{
$this->connection->query(sprintf('
INSERT INTO
`annotation`
VALUES (
null,
"%s",
%s,
%s,
"%s",
"%s",
"%s",
null
)', $this->connection->escape_string($annotation->file), (int) $annotation->line, (int) $annotation->character, $this->connection->escape_string($annotation->type), $this->connection->escape_string($annotation->class), $this->connection->escape_string($annotation->message)));
}
示例2: escape
function escape($value)
{
return $this->link->escape_string($value);
}
示例3: search
public function search(array $fields, &$text)
{
static $min_word_len = 0;
/*
* Short words are ignored, the default minimum length is 4 characters. You can change the min and max word length with the variables ft_min_word_len and ft_max_word_len
* Words called stopwords are ignored, you can specify your own stopwords, but default words include the, have, some - see default stopwords list.
* You can disable stopwords by setting the variable ft_stopword_file to an empty string.
* http://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html
*/
if (!$min_word_len) {
mysqli_report(MYSQLI_REPORT_OFF);
if ($res = parent::query('SHOW VARIABLES LIKE \'ft_min_word_len\'')) {
$min_word_len = $res->fetch_row();
$min_word_len = intval($min_word_len[1]);
$res->free();
}
mysqli_report(MYSQLI_REPORT_ERROR);
$min_word_len = max($min_word_len, 3);
}
$text = Poodle_Unicode::as_search_txt($text);
if (preg_match_all('#[^\\s]{' . $min_word_len . ',}#', $text, $match)) {
$text = $match[0];
}
return ' MATCH (' . implode(',', $fields) . ') AGAINST (\'' . parent::escape_string(implode(' ', $text)) . '\') ';
}
示例4: escape
/**
* Escapes a string for entry into the database
*
* @param string $string
* @return string
*/
public function escape($string)
{
$this->_getDbh();
return $this->_dbh->escape_string($string);
}
示例5: MySQLi
<?php
// codes for searching ---------
$db = new MySQLi('localhost', 'root', 'xxxx', 'xxxx');
if (isset($_GET['keywords'])) {
$keywords = $db->escape_string($_GET['keywords']);
$query = $db->query("\r\n\t\tSELECT movie_id, movie_name \r\n\t\tFROM movie\r\n\t\tWHERE movie_name LIKE '%{$keywords}%'\r\n\t\tOR actor LIKE '%{$keywords}%'\r\n\t\tLIMIT 20\r\n\t");
?>
<div class="result-count">
Found <?php
echo $query->num_rows;
?>
results.
</div>
<?php
include 'core/init.php';
include 'includes/overall/headder.php';
include 'includes/widgets/spacer.php';
include 'search.php';
include 'includes/widgets/spacer.php';
if ($query->num_rows) {
while ($r = $query->fetch_object()) {
//object because using oops style ( mysqli )
?>
<div id="search_result">
<a href="moviehomepage.php?movie_id=<?php
echo $r->movie_id;
?>
"><?php