diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-03-16 17:38:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-03-16 17:38:51 +0000 |
commit | b2583b624cea1f42f5c3633a331648d85b0e14cc (patch) | |
tree | 0b420fa40c14911d94034870533f05495b0433d6 /includes | |
parent | 583104ce286c822b658937ea03a8b0981c82a474 (diff) | |
download | brdo-b2583b624cea1f42f5c3633a331648d85b0e14cc.tar.gz brdo-b2583b624cea1f42f5c3633a331648d85b0e14cc.tar.bz2 |
Patch by Ax:
- db_query_range() in database.mysql.inc wasn't updated to match
db_query().
- Fixed phpdoc.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/database.mysql.inc | 28 | ||||
-rw-r--r-- | includes/database.pear.inc | 13 |
2 files changed, 24 insertions, 17 deletions
diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc index d2f4aee04..301bfb567 100644 --- a/includes/database.mysql.inc +++ b/includes/database.mysql.inc @@ -118,18 +118,26 @@ function db_affected_rows() { } /** - * Generates a limited query + * Runs a LIMIT query in the database. * - * @param string $query query - * @param integer $from the row to start to fetching - * @param integer $count the numbers of rows to fetch - * - * @access public + * @param mixed $query SQL query, followed by a variable number of arguments which are substituted into query by sprintf, followed by 'from' and 'count' parameters. 'from' is the row to start fetching, 'count' the numbers of rows to fetch. + * @return resource a MySQL result or FALSE if the query was not executed correctly. + * @access public */ -function db_query_range($query, $from, $count) { +function db_query_range($query) { + $args = func_get_args(); + $count = array_pop($args); + $from = array_pop($args); + if (count(func_get_args()) > 3) { + $args = array_map("check_query", $args); + $args[0] = $query; + $query = call_user_func_array("sprintf", $args); + } + else { + $query = func_get_arg(0); + } $query .= " LIMIT $from, $count"; - // TODO: debug version - return db_query($query); + return _db_query($query); } -?>
\ No newline at end of file +?> diff --git a/includes/database.pear.inc b/includes/database.pear.inc index 0b56efcdf..f4620f824 100644 --- a/includes/database.pear.inc +++ b/includes/database.pear.inc @@ -18,9 +18,9 @@ function db_connect($url) { /** * Runs a query in the database. * - * @param $query sql query - * @param $type module type of this item - * @return sql result resource + * @param $query SQL query + * @param $type module type of this item + * @return sql result resource */ function db_query($query) { @@ -130,9 +130,8 @@ function db_affected_rows() { /** * Runs a LIMIT query in the database. * - * @param $query sql query followed by 'from' and 'count' parameters, followed by a variable number of arguments which are substituted into query by sprintf. 'from' is the row to start to fetching. 'count' the numbers of rows to fetch. - * @return mixed a DB_Result object or a DB_Error - * + * @param mixed $query SQL query followed by a variable number of arguments which are substituted into query by sprintf, followed by 'from' and 'count' parameters. 'from' is the row to start fetching, 'count' the numbers of rows to fetch. + * @return mixed a DB_Result object or a DB_Error * @access public */ function db_query_range($query) { @@ -170,4 +169,4 @@ function db_query_range($query) { } } -?>
\ No newline at end of file +?> |