From a2fe7433ccae56205b35917b58ed2d7d3e650c8e Mon Sep 17 00:00:00 2001 From: Marc Boeren Date: Tue, 5 Jun 2001 13:42:18 +0000 Subject: [PATCH] dbx_cmp_asc and dbx_cmp_desc functions are removed. dbx_compare function is added (with DBX_CMP_ASC, DBX_CMP_DESC flags) dbx_connect returns 0 if database is not found, even though connect succeeded git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@49229 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/dbx.xml | 105 ++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 79 deletions(-) diff --git a/functions/dbx.xml b/functions/dbx.xml index ac8e28ac5c..94e3ae63e6 100644 --- a/functions/dbx.xml +++ b/functions/dbx.xml @@ -89,10 +89,10 @@ dbx_close($link); Returns: a dbx_link_object on success, FALSE - on error. If a connection can be made but the database could not - be selected, the function still returns a dbx_link_object. The - 'persistent' parameter can be set to DBX_PERSISTENT so a - persistent connection will be created. + on error. If a connection has been made but the database could not + be selected, the connection is closed and FALSE + is returned. The 'persistent' parameter can be set to + DBX_PERSISTENT so a persistent connection will be created. The module parameter can be either a string @@ -396,8 +396,8 @@ dbx_close($link); <?php function user_re_order ($a, $b) { - $rv = dbx_cmp_desc ($a, $b, "parentid"); - if (!$rv) $rv = dbx_cmp_asc ($a, $b, "id"); + $rv = dbx_compare ($a, $b, "parentid", DBX_CMP_DESC); + if (!$rv) $rv = dbx_compare ($a, $b, "id"); return $rv; } @@ -412,48 +412,53 @@ dbx_close ($link); - See also dbx_cmp_asc and - dbx_cmp_desc. + See also dbx_compare. - + - dbx_cmp_asc - Compare two rows for sorting in ascending order + dbx_compare + Compare two rows for sorting purposes Description - int dbx_cmp_asc + int dbx_compare array row_a array row_b string columnname_or_index int - comparison_type + flags 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. + smaller (or vice versa if the DBX_CMP_DESC flag is set). - 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"). + The flags can be set to specify comparison + direction (whether sorting is ascending or descending) and + comparison type (force string or numeric compare by converting the + data). The constants for direction are DBX_CMP_ASC and DBX_CMP_DESC. + The constants for comparison type are DBX_CMP_NATIVE (no + conversion), DBX_CMP_TEXT and DBX_CMP_NUMBER. These constants can + be OR-ed together. The default value for the + flags parameter is DBX_CMP_ASC | + DBX_CMP_NATIVE. - <function>dbx_cmp_asc</function> example + <function>dbx_compare</function> example <?php function user_re_order ($a, $b) { - $rv = dbx_cmp_desc ($a, $b, "parentid"); + $rv = dbx_compare ($a, $b, "parentid", DBX_CMP_DESC); if (!$rv) { - $rv = dbx_cmp_asc ($a, $b, "id"); + $rv = dbx_compare ($a, $b, "id"); return $rv; } } @@ -469,69 +474,11 @@ dbx_close ($link); - See also dbx_sort and - dbx_cmp_desc. + See also dbx_sort. - - - - 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 - int - comparison_type - - - - - 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. - - - 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"). - - - <function>dbx_cmp_desc</function> example - -<?php -function user_re_order ($a, $b) { - $rv = dbx_cmp_desc ($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_sort ($result, "user_re_order"); -echo "resulting data is now ordered by parentid (descending), then by id<br>"; -dbx_close ($link); -?> - - - - See also dbx_sort and - dbx_cmp_asc. - - - -