php man page for dbx_compare

Query: dbx_compare

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

DBX_COMPARE(3)								 1							    DBX_COMPARE(3)

dbx_compare - Compare two rows for sorting purposes

SYNOPSIS
int dbx_compare (array $row_a, array $row_b, string $column_key, [int $flags = DBX_CMP_ASC | DBX_CMP_NATIVE])
DESCRIPTION
dbx_compare(3) is a helper function for dbx_sort(3) to ease the make and use of the custom sorting function.
PARAMETERS
o $row_a - First row o $row_b - Second row o $column_key - The compared column o $flags - The $flags can be set to specify comparison direction: o DBX_CMP_ASC - ascending order o DBX_CMP_DESC - descending order and the preferred comparison type: o DBX_CMP_NATIVE - no type conversion o DBX_CMP_TEXT - compare items as strings o DBX_CMP_NUMBER - compare items numerically One of the direction and one of the type constant can be combined with bitwise OR operator (|).
RETURN VALUES
Returns 0 if the row_a[$column_key] is equal to row_b[$column_key], and 1 or -1 if the former is greater or is smaller than the latter one, respectively, or vice versa if the $flag is set to DBX_CMP_DESC.
EXAMPLES
Example #1 dbx_compare(3) example <?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; } $link = dbx_connect(DBX_ODBC, "", "db", "username", "password") or die("Could not connect"); $result = dbx_query($link, "SELECT id, parentid, description FROM table ORDER BY id"); // data in $result is now ordered by id dbx_sort($result, "user_re_order"); // date in $result is now ordered by parentid (descending), then by id dbx_close($link); ?>
SEE ALSO
dbx_sort(3). PHP Documentation Group DBX_COMPARE(3)
Related Man Pages
mysqli_fetch_array(3) - php
dbx_connect(3) - php
array_unique(3) - php
dbx_compare(3) - php
maxdb_fetch_row(3) - php
Similar Topics in the Unix Linux Community
Loop Problem
Loop Problem
how to list descending order