Fixed examples for dbx_sort, dbx_cmp_asc and dbx_cmp_desc.

Added the optional comparison_type parameter to dbx_cmp_asc and
dbx_cmp_desc (Mc)


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@45469 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Marc Boeren 2001-04-18 12:39:17 +00:00
parent 2097fb6abb
commit 8fdd2e80b1

View file

@ -391,7 +391,7 @@ dbx_close($link);
<programlisting role="php">
&lt;?php
function user_re_order ($a, $b) {
$rv = dbx_cmp_asc ($a, $b, "parentid");
$rv = dbx_cmp_desc ($a, $b, "parentid");
if (!$rv) $rv = dbx_cmp_asc ($a, $b, "id");
return $rv;
}
@ -400,8 +400,8 @@ $link = dbx_connect ("odbc", "", "db", "username", "password")
or die ("Could not connect");
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
echo "resulting data is now ordered by id&lt;br>";
dbx_query ($result, "user_re_order");
echo "resulting data is now ordered by parentid, then by id&lt;br>";
dbx_sort ($result, "user_re_order");
echo "resulting data is now ordered by parentid (descending), then by id&lt;br>";
dbx_close ($link);
?&gt;
</programlisting>
@ -426,6 +426,9 @@ dbx_close ($link);
<paramdef>array <parameter>row_a</parameter></paramdef>
<paramdef>array <parameter>row_b</parameter></paramdef>
<paramdef>string <parameter>columnname_or_index</parameter></paramdef>
<paramdef>int
<parameter><optional>comparison_type</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
@ -433,12 +436,17 @@ dbx_close ($link);
row_b[$columnname_or_index], 1 if it is greater and -1 if it is
smaller.
</para>
<para>
The <parameter>comparison_type</parameter> parameter can be used
to force a numeric compare (by setting it to DBX_CMP_NUMBER). The default
comparison is by text (e.g. "20" is greater than "100").
</para>
<example>
<title><function>dbx_cmp_asc</function> example</title>
<programlisting role="php">
&lt;?php
function user_re_order ($a, $b) {
$rv = dbx_cmp_asc ($a, $b, "parentid");
$rv = dbx_cmp_desc ($a, $b, "parentid");
if (!$rv) {
$rv = dbx_cmp_asc ($a, $b, "id");
return $rv;
@ -449,8 +457,8 @@ $link = dbx_connect ("odbc", "", "db", "username", "password")
or die ("Could not connect");
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
echo "resulting data is now ordered by id&lt;br>";
dbx_query ($result, "user_re_order");
echo "resulting data is now ordered by parentid, then by id&lt;br>";
dbx_sort ($result, "user_re_order");
echo "resulting data is now ordered by parentid (descending), then by id&lt;br>";
dbx_close ($link);
?&gt;
</programlisting>
@ -474,8 +482,9 @@ dbx_close ($link);
<funcdef>int <function>dbx_cmp_desc</function></funcdef>
<paramdef>array <parameter>row_a</parameter></paramdef>
<paramdef>array <parameter>row_b</parameter></paramdef>
<paramdef>string
<parameter>columnname_or_index</parameter>
<paramdef>string <parameter>columnname_or_index</parameter></paramdef>
<paramdef>int
<parameter><optional>comparison_type</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
@ -484,12 +493,17 @@ dbx_close ($link);
row_b[$columnname_or_index], -1 if it is greater and 1 if it is
smaller.
</para>
<para>
The <parameter>comparison_type</parameter> parameter can be used
to force a numeric compare (by setting it to DBX_CMP_NUMBER). The default
comparison is by text (e.g. "20" is greater than "100").
</para>
<example>
<title><function>dbx_cmp_desc</function> example</title>
<programlisting role="php">
&lt;?php
function user_re_order ($a, $b) {
$rv = dbx_cmp_asc ($a, $b, "parentid");
$rv = dbx_cmp_desc ($a, $b, "parentid");
if (!$rv) {
$rv = dbx_cmp_asc($a, $b, "id");
return $rv;
@ -500,8 +514,8 @@ $link = dbx_connect ("odbc", "", "db", "username", "password")
or die ("Could not connect");
$result = dbx_query ($link, "SELECT id, parentid, description FROM tbl ORDER BY id");
echo "resulting data is now ordered by id&lt;br>";
dbx_query ($result, "user_re_order");
echo "resulting data is now ordered by parentid, then by id&lt;br>";
dbx_sort ($result, "user_re_order");
echo "resulting data is now ordered by parentid (descending), then by id&lt;br>";
dbx_close ($link);
?&gt;
</programlisting>