Beispiel #1
0
 /**
  * Gets detailed information about packages in a category.
  *
  * @param integer $categoryId the category to for which to get package
  *                            information.
  * @param string  $php        optional. The PHP version on which to filter.
  *                            If not specified, defaults to 'all'.
  *
  * @return array an array of packages with each array element being an array
  *               containing information about a specific package.
  */
 protected function getPackages($categoryId, $php = 'all')
 {
     $sql = '
         SELECT
             p.id, p.name, p.summary, p.license, p.unmaintained, p.newpk_id,
             (SELECT COUNT(package) FROM releases WHERE package = p.id) AS numreleases,
             (SELECT state FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS status,
             (SELECT version FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS version,
             (SELECT releasedate FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS releasedate,
             (SELECT COUNT(1)
                 FROM bugdb
                 WHERE package_name = p.name AND status IN
                     (\'Open\', \'Verified\',  \'Assigned\')
             ) as numbugs
         FROM packages p';
     $sql .= $this->getPhpVersionJoinClause($php);
     $sql .= '
         WHERE
             p.package_type = ? AND p.approved = 1 AND p.category = ?';
     $sql .= $this->getPhpVersionWhereClause($php);
     if ($php != 'all') {
         $sql .= '
             GROUP BY p.id';
     }
     $sql .= '
         ORDER BY p.name ASC';
     $this->dbh->setFetchmode(DB_FETCHMODE_ASSOC);
     return $this->dbh->getAll($sql, array(SITE, $categoryId));
 }