Re: [aur-dev] [aur-general] Method to get all Packages
On Sun, Jan 25, 2009 at 06:55:05PM +0100, Lukas Appelhans wrote:
Okok :) I worked on a patch for that, it's attached... I have no clue if it works (or if everything is alright) though, never worked with Sql-Queries :(
Alright this is definitely in the aur-dev realm now. Please send patches/ideas to aur-dev@archlinux.org. I still don't understand why you need all packages. Maybe you can explain that first. Cheers.
diff --git a/web/html/rpc.php b/web/html/rpc.php index 033cba5..d58a487 100644 --- a/web/html/rpc.php +++ b/web/html/rpc.php @@ -19,6 +19,7 @@ if ( $_SERVER['REQUEST_METHOD'] == 'GET' ) { echo '<ul>'; echo '<li>search</li>'; echo '<li>info</li>'; + echo '<li>all_packages</li>'; echo '</ul><br />'; echo 'Each method requires the following HTTP GET syntax:<br />'; echo ' type=<i>methodname</i>&arg=<i>data</i> <br /><br />'; diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 81c0831..c30eeef 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -21,7 +21,7 @@ if (!extension_loaded('json')) **/ class AurJSON { private $dbh = false; - private $exposed_methods = array('search','info'); + private $exposed_methods = array('search','info','all_packages'); private $fields = array('ID','Name','Version','CategoryID','Description', 'URL','URLPath','License','NumVotes','OutOfDate');
@@ -147,5 +147,28 @@ class AurJSON { return $this->json_error('No result found'); } } + + /** + * Returns all packages + */ + private function all_packages() { + $query = "SELECT " . implode(',', $this->fields) . + " FROM Packages WHERE DummyPkg=0 "; + + $result = db_query($query, $this->dbh); + + if ( $result && (mysql_num_rows($result) > 0) ) { + $search_data = array(); + while ( $row = mysql_fetch_assoc($result) ) { + array_push($search_data, $row); + } + + mysql_free_result($result); + return $this->json_results('all_packages', $search_data); + } + else { + return $this->json_error('No results found'); + } + } }
participants (1)
-
Loui Chang