php-doc-en/reference/sqlite/functions/sqlite-udf-decode-binary.xml
Daniel Egeberg 96c9d88bad Converted to utf-8
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
2010-03-28 22:10:10 +00:00

135 lines
3.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sqlite-udf-decode-binary" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>sqlite_udf_decode_binary</refname>
<refpurpose>Decode binary data passed as parameters to an <acronym>UDF</acronym></refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>sqlite_udf_decode_binary</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
</methodsynopsis>
<para>
Decodes binary data passed as parameters to a <acronym>UDF</acronym>.
</para>
<para>
You must call this function on parameters passed to your UDF if you need
them to handle binary data, as the binary encoding employed by PHP will
obscure the content and of the parameter in its natural, non-coded form.
</para>
<para>
PHP does not perform this encode/decode operation automatically as it would
severely impact performance if it did.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
The encoded data that will be decoded, data that was applied by either
<function>sqlite_udf_encode_binary</function> or
<function>sqlite_escape_string</function>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The decoded <type>string</type>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>binary-safe max_length aggregation function example</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array(
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten',
);
$db = sqlite_open(':memory:');
sqlite_query($db, "CREATE TABLE strings(a)");
foreach ($data as $str) {
$str = sqlite_escape_string($str);
sqlite_query($db, "INSERT INTO strings VALUES ('$str')");
}
function max_len_step(&$context, $string)
{
$string = sqlite_udf_decode_binary($string);
if (strlen($string) > $context) {
$context = strlen($string);
}
}
function max_len_finalize(&$context)
{
return $context;
}
sqlite_create_aggregate($db, 'max_len', 'max_len_step', 'max_len_finalize');
var_dump(sqlite_array_query($db, 'SELECT max_len(a) from strings'));
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>sqlite_udf_encode_binary</function></member>
<member><function>sqlite_create_function</function></member>
<member><function>sqlite_create_aggregate</function></member>
</simplelist>
</para>
</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
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
-->