📄 function.sqlite-escape-string.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Escapes a string for use as a query parameter</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.sqlite-error-string.html">sqlite_error_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sqlite-exec.html">sqlite_exec</a></div> <div class="up"><a href="ref.sqlite.html">SQLite Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.sqlite-escape-string" class="refentry"> <div class="refnamediv"> <h1 class="refname">sqlite_escape_string</h1> <p class="verinfo">(PHP 5, PECL sqlite:1.0-1.0.3)</p><p class="refpurpose"><span class="refname">sqlite_escape_string</span> — <span class="dc-title">Escapes a string for use as a query parameter</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>sqlite_escape_string</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$item</tt></span> )</div> <p class="para rdfs-comment"> <b>sqlite_escape_string()</b> will correctly quote the string specified by <i><tt class="parameter">item</tt></i> for use in an SQLite SQL statement. This includes doubling up single-quote characters (<i>'</i>) and checking for binary-unsafe characters in the query string. </p> <p class="para"> Although the encoding makes it safe to insert the data, it will render simple text comparisons and <i>LIKE</i> clauses in your queries unusable for the columns that contain the binary data. In practice, this shouldn't be a problem, as your schema should be such that you don't use such things on binary columns (in fact, it might be better to store binary data using other means, such as in files). </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">item</tt></i></span> <dd> <p class="para"> The <a href="language.types.string.html" class="type string">string</a> being quoted. </p> <p class="para"> If the <i><tt class="parameter">item</tt></i> contains a <i>NUL</i> character, or if it begins with a character whose ordinal value is <i>0x01</i>, PHP will apply a binary encoding scheme so that you can safely store and retrieve binary data. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an escaped <a href="language.types.string.html" class="type string">string</a> for use in an SQLite SQL statement. </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <span class="simpara"> Do not use this function to encode the return values from UDF's created using <a href="function.sqlite-create-function.html" class="function">sqlite_create_function()</a> or <a href="function.sqlite-create-aggregate.html" class="function">sqlite_create_aggregate()</a> - use <a href="function.sqlite-udf-encode-binary.html" class="function">sqlite_udf_encode_binary()</a> instead. </span> </p></blockquote> <div class="warning"><b class="warning">Warning</b> <p class="simpara"> <a href="function.addslashes.html" class="function">addslashes()</a> should <em class="emphasis">NOT</em> be used to quote your strings for SQLite queries; it will lead to strange results when retrieving your data. </p> </div> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.sqlite-udf-encode-binary.html" class="function" rel="rdfs-seeAlso">sqlite_udf_encode_binary()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.sqlite-error-string.html">sqlite_error_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sqlite-exec.html">sqlite_exec</a></div> <div class="up"><a href="ref.sqlite.html">SQLite Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -