php-doc-en/reference/cubrid/functions/cubrid-real-escape-string.xml
2010-11-11 11:08:55 +00:00

96 lines
2.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.cubrid-real-escape-string" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>cubrid_real_escape_string</refname>
<refpurpose>Returns the escaped string version of the given string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>cubrid_real_escape_string</methodname>
<methodparam><type>string</type><parameter>unescaped_string</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>conn_identifier</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the escaped string version of the given string. It pre-appends backslashes to the following characters: <constant>'</constant>. This function must always (with few exceptions) be used to make data safe before sending a query to CUBRID.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>unescaped_string</parameter></term>
<listitem><para>The string that is to be escaped.</para></listitem>
</varlistentry>
<varlistentry>
<term><parameter>conn_identifier</parameter></term>
<listitem><para>The CUBRID connection. If the connection identifier is not specified, the last link opened by <function>cubrid_connect</function> is assumed.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Escaped string version of the given string, on success.
</para>
<para>
&false; on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>cubrid_real_escape_string</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$user = "'username'";
$password = "\"pass\"";
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
cubrid_real_escape_string($user),
cubrid_real_escape_string($password));
echo $query;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Result:
SELECT * FROM users WHERE user='\'username\'' AND password='"pass"'
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->