diff --git a/functions/dbx.xml b/functions/dbx.xml
index f666adc915..299d1b86df 100644
--- a/functions/dbx.xml
+++ b/functions/dbx.xml
@@ -391,7 +391,7 @@ dbx_close($link);
<?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<br>";
-dbx_query ($result, "user_re_order");
-echo "resulting data is now ordered by parentid, then by id<br>";
+dbx_sort ($result, "user_re_order");
+echo "resulting data is now ordered by parentid (descending), then by id<br>";
dbx_close ($link);
?>
@@ -426,6 +426,9 @@ dbx_close ($link);
array row_a
array row_b
string columnname_or_index
+ int
+ comparison_type
+
@@ -433,12 +436,17 @@ dbx_close ($link);
row_b[$columnname_or_index], 1 if it is greater and -1 if it is
smaller.
+
+ The comparison_type 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").
+
dbx_cmp_asc example
<?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<br>";
-dbx_query ($result, "user_re_order");
-echo "resulting data is now ordered by parentid, then by id<br>";
+dbx_sort ($result, "user_re_order");
+echo "resulting data is now ordered by parentid (descending), then by id<br>";
dbx_close ($link);
?>
@@ -474,8 +482,9 @@ dbx_close ($link);
int dbx_cmp_desc
array row_a
array row_b
- string
- columnname_or_index
+ string columnname_or_index
+ int
+ comparison_type
@@ -484,12 +493,17 @@ dbx_close ($link);
row_b[$columnname_or_index], -1 if it is greater and 1 if it is
smaller.
+
+ The comparison_type 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").
+
dbx_cmp_desc example
<?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<br>";
-dbx_query ($result, "user_re_order");
-echo "resulting data is now ordered by parentid, then by id<br>";
+dbx_sort ($result, "user_re_order");
+echo "resulting data is now ordered by parentid (descending), then by id<br>";
dbx_close ($link);
?>