dbx_cmp_desc

(PHP 4 CVS only)

dbx_cmp_desc -- Compare two rows for sorting in descending order

Description

int dbx_cmp_desc (array row_a, array row_b, string columnname_or_index)

Returns 0 if row_a[$columnname_or_index] is equal to row_b[$columnname_or_index], -1 if it is greater and 1 if it is smaller.

Example 1. dbx_cmp_desc() example


<?php
function user_re_order ($a, $b) {
    $rv = dbx_cmp_asc ($a, $b, "parentid");
    if (!$rv) {
        $rv = dbx_cmp_asc($a, $b, "id");
        return $rv;
    }
}

$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_close ($link);
?>
     

See also dbx_sort() and dbx_cmp_asc().