Selects records up to $limit from connected database according to given condition and optionally sorts them.
This function returns array or null, if nothing has been selected.
$x = ptb_select($myDatabase, "'age' > 40", 'birth DESC'); $x = ptb_select($myDatabase, "'age' > 40 AND 'sex' == 'M'", 'name ASC, birth DESC'); $x = ptb_select($myDatabase, "even('age')"); $x = ptb_select($myDatabase, "'name' == '{$_GET['name']}'"); $x = ptb_select($db_test, "'id' == '{$db_test1[1]['price']}'");
Order of $limit and $sort arguments doesn't really matter; if you want to set only $limit, you can simply use:
$x = ptb_select($myDatabase, "even('age')", 10);
If value of multidimensional table is to appear in $condition, use {} to surround the expression (see the last example above; braces were rendered bold to increase visibility).
If you need only one record, always use $limit = 1 to speed up the function.
If you need all the records, you needn't use ptb_select at all, since the variable you used to connect to the data file already contains them!
If you want to find value of one (unique or just first) field of a record, in which another field is equal to a given value, you should use ptb_map instead.
If you want to search the database for records containing specified text in certain field, eg. author, you can use eregi() function:
$x = ptb_select($myDatabase, "eregi('text_to_look_for', 'author')");