DBX_SORT(3) 1 DBX_SORT(3)dbx_sort - Sort a result from a dbx_query by a custom sort functionSYNOPSIS
bool dbx_sort (object $result, string $user_compare_function)
DESCRIPTION
Sort a result from a dbx_query(3) call with a custom sort function.
PARAMETERS
o $result
- A result set returned by dbx_query(3).
o $user_compare_function
- The user-defined comparison function. It must accept two arguments and return an integer less than, equal to, or greater than
zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
dbx_sort(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 tbl ORDER BY id");
// data in $result is now ordered by id
dbx_sort($result, "user_re_order");
// data in $result is now ordered by parentid (descending), then by id
dbx_close($link);
?>
NOTES
Note
It is always better to use ORDER BY SQL clause instead of dbx_sort(3) if possible.
SEE ALSO dbx_compare(3).
PHP Documentation Group DBX_SORT(3)
Check Out this Related Man Page
DBX_ESCAPE_STRING(3) 1 DBX_ESCAPE_STRING(3)dbx_escape_string - Escape a string so it can safely be used in an sql-statementSYNOPSIS
string dbx_escape_string (object $link_identifier, string $text)
DESCRIPTION
Escape the given string so that it can safely be used in an sql-statement.
PARAMETERS
o $link_identifier
- The DBX link object returned by dbx_connect(3)
o $text
- The string to escape.
RETURN VALUES
Returns the text, escaped where necessary (such as quotes, backslashes etc). On error, NULL is returned.
EXAMPLES
Example #1
dbx_escape_string(3) example
<?php
$link = dbx_connect(DBX_MYSQL, "localhost", "db", "username", "password")
or die("Could not connect");
$text = dbx_escape_string($link, "It's quoted and backslashed (\).");
$result = dbx_query($link, "insert into tbl (txt) values ('" . $text . "')");
if ($result == 0) {
echo dbx_error($link);
}
dbx_close($link);
?>
SEE ALSO dbx_query(3).
PHP Documentation Group DBX_ESCAPE_STRING(3)
Hello all
Im trying to write one liner that will show me results only if the result of the expression is greater then 0
For example:
I do :
find . -name "*.dsp" | xargs grep -c SecurityHandler
the result are :
./foo/blah/a.dsp:0
./foo/blah1/b.dsp:1
./foo/blah2/c.dsp:2... (1 Reply)
Hi ,
I have a file like this
parentid process id
45 3456
1 7898
45 7890
1 6789
45 7597
now i need to loop through this and if parentid != 45 , then... (4 Replies)
i could like to try when i input a integer , the program would give the result i want but it doesnt .
http://i.imgur.com/LqOczGM.jpg
I input 2 , and the result should be "it is greater than or equal to one"
could any ching give me improvement ? If i must use case command .
thank you... (14 Replies)