mirror of
https://github.com/php/doc-es.git
synced 2026-03-28 09:22:15 +01:00
Use consistent line terminator. git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@317671 c90b9560-bf6c-de11-be94-00142212c4b1
128 lines
3.4 KiB
XML
128 lines
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: seros Status: ready -->
|
|
<refentry xml:id="function.dbx-sort" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>dbx_sort</refname>
|
|
<refpurpose>
|
|
Ordenar un resultado de una llamada a dbx_query mediante una función de ordenación personalizada
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>dbx_sort</methodname>
|
|
<methodparam><type>object</type><parameter>result</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>user_compare_function</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Ordena un resultado de una llamada a <function>dbx_query</function> con una función de ordenación
|
|
personalizada.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>result</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un conjunto de resultados devueltos por <function>dbx_query</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>user_compare_function</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La función de comparación definida por el usuario. Debe aceptar dos argumentosy
|
|
devolver un entero menor que, igual que, mayor que cero si el
|
|
primer argumento se considera respectivamente menor que, igual que
|
|
o mayor que el segundo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>dbx_sort</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function user_re_order($a, $b)
|
|
{
|
|
$rv = dbx_compare($a, $b, "parentid", DBX_CMP_DESC);
|
|
if (!$rv) {
|
|
$rv = dbx_compare($a, $b, "id", DBX_CMP_NUMBER);
|
|
}
|
|
return $rv;
|
|
}
|
|
|
|
$enlace = dbx_connect(DBX_ODBC, "", "db", "username", "password")
|
|
or die("No se pudo conectar");
|
|
|
|
$resultado = dbx_query($enlace, "SELECT id, parentid, description FROM tbl ORDER BY id");
|
|
// la información de $resultado está ordenada ahora por id
|
|
|
|
dbx_sort($resultado, "user_re_order");
|
|
// la información de $resultado está ordenada por parentid (descendentemente), luego por id
|
|
|
|
dbx_close($enlace);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Siempre es mejor usar la cláusula <literal>ORDER BY</literal>
|
|
<literal>SQL</literal> en vez de <function>dbx_sort</function>
|
|
mientras sea posible.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>dbx_compare</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
|
|
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
|
|
-->
|