<?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>Escape special characters in a string for use in an SQL statement</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
    will escape the following characters: <constant>'</constant>. 

    In general, single quotations are used to enclose character string. Double
    quotations may be used as well depending on the value of ansi_quotes,
    which is a parameter related to SQL statement. If the ansi_quotes value is
    set to no, character string enclosed by double quotations is handled as
    character string, not as an identifier. The default value is yes.

    If you want to include a single quote as part of a character string, enter
    two single quotes in a row.
  </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 connection 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
$conn = cubrid_connect("localhost", 33000, "demodb");

$unescaped_str = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$escaped_str = cubrid_real_escape_string($unescaped_str);

$len = strlen($unescaped_str);

@cubrid_execute($conn, "DROP TABLE cubrid_test");
cubrid_execute($conn, "CREATE TABLE cubrid_test (t char($len))");
cubrid_execute($conn, "INSERT INTO cubrid_test (t) VALUES('$escaped_str')");

$req = cubrid_execute($conn, "SELECT * FROM cubrid_test");
$row = cubrid_fetch_assoc($req);

var_dump($row);

cubrid_close_request($req);
cubrid_disconnect($conn);
?>
]]>
   </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
array(1) {
  ["t"]=>
  string(95) " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
}
]]>
    </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
-->
