/** * @see DB_common::getOne */ public function getOne($query, $params = array()) { $query = $this->quoteSql($query, $params); $res = $this->db->getOne($query, $params); $this->assertError($res); return $res; }
private function getNumberAds($cat_id) { $result = 0; $q = 'SELECT COUNT(*) FROM ' . $this->mTbCompanies . ' WHERE id_cat = \'' . $cat_id . '\''; $result += $this->mDb->getOne($q); $q = 'SELECT id FROM ' . $this->mTbCats . ' WHERE parent = "' . $cat_id . '" AND active = 1'; $db =& $this->mDb->query($q); $res = array(); while ($row = $db->fetchRow()) { $result += $this->getNumberAds($row['id']); } return $result; }
/** * Fetch the first column of the first row of data returned from * a query. Takes care of doing the query and freeing the results * when finished. * * @param $query the SQL query * @param $data if supplied, prepare/execute will be used * with this array as execute parameters * @param string $action type of request to perform, defaults to search (ldap_search()) * @param array $params array of additional parameters to pass to the PHP ldap function requested * @return array * @see DB_common::getOne() * @access public */ function &getOne($query, $data = array(), $action = null, $params = array()) { $this->q_action = $action ? $action : $this->action; $this->q_params = $params; return parent::getOne($query, $data); }
/** * Fetch the first column of the first row of data returned from * a query. Takes care of doing the query and freeing the results * when finished. * * @param $query the SQL query * @param $data if supplied, prepare/execute will be used * with this array as execute parameters * @param string $action type of request to perform, defaults to search (ldap_search()) * @param array $params array of additional parameters to pass to the PHP ldap function requested * @return array * @see DB_common::getOne() * @access public */ function &getOne($query, $data = array(), $action = 'search', $params = array()) { $this->q_action = $action; $this->q_params = $params; return parent::getOne($query, $data); }
/** * Displays package information for the specified package * * @param array $package associative array containing package information. * @param string $php optional. The PHP version on which to filter. * If not specified, defaults to 'all'. * @param integer $count optional. The ordinal index of the package * being displayed. * * @return null */ protected function displayPackage(array $package, $php = 'all', $count = 0) { $packageClass = $count === 0 ? 'package package-first' : 'package'; echo " <div class=\"{$packageClass}\">\n"; echo " <div class=\"package-info\">\n"; // name $packageName = htmlspecialchars($package['name']); echo " <div class=\"package-title\">\n"; echo " <a href=\"package/{$packageName}\">{$packageName}</a>\n"; echo " </div>\n"; // summary $packageSummary = trim(htmlspecialchars($package['summary'])); echo " <div class=\"package-description\">\n"; echo " <p>{$packageSummary}</p>\n"; echo " </div>\n"; // deprecated note if (!empty($package['newpk_id'])) { echo " <div class=\"package-notes\">\n"; $newPackageName = $this->dbh->getOne('SELECT name FROM packages WHERE id = ' . $this->dbh->quote($package['newpk_id'], 'text') . ' ORDER BY id DESC LIMIT 1'); $newPackageName = htmlspecialchars($newPackageName); echo " <p>This package has been deprecated in favor of " . "<a href=\"/package/{$newPackageName}\">" . $newPackageName . "</a>.</p>"; echo " </div>\n"; } echo " </div>\n"; echo " <div class=\"package-more-info\">\n"; echo " <table class=\"package-data\">\n"; echo " <tbody>\n"; // status switch ($package['status']) { case 'stable': $state = '<span class="package-stable">stable</span>'; break; case 'beta': $state = '<span class="package-beta">beta</span>'; break; case 'alpha': default: $state = '<span class="package-alpha">alpha</span>'; break; } $timestamp = strtotime($package['releasedate']); $packageVersion = htmlspecialchars($package['version']); $packageDateIso = htmlspecialchars(date('c', $timestamp)); $packageDate = htmlspecialchars(date('Y-m-d', $timestamp)); echo " <tr>\n"; echo " <th>Status:</th>\n"; echo " <td>" . $packageVersion . " " . "(" . $state . ") " . "released on <abbr class=\"date\" title=\"{$packageDateIso}\">" . $packageDate . "</abbr>" . "</td>\n"; echo " </tr>\n"; // license $packageLicense = htmlspecialchars($package['license']); $packageLicenseStatus = license::isGood($package['license']); $packageLicenseLink = license::getLink($package['license']); $packageLicenseClass = $packageLicenseStatus ? 'package-license-good' : 'package-license-bad'; echo " <tr>\n"; echo " <th>License:</th>\n"; echo " <td>"; echo "<span class=\"{$packageLicenseClass}\">"; if ($packageLicenseLink === null) { echo $packageLicense; } else { echo "<a href=\"{$packageLicenseLink}\">{$packageLicense}</a>"; } echo "</span>"; echo "</td>\n"; echo " </tr>\n"; // maintained echo " <tr>\n"; echo " <th>Maintained:</th>\n"; echo " <td>"; if ($package['unmaintained'] == 0) { echo "Yes"; } else { echo "<span class=\"package-unmaintained\">No</span>"; } echo "</td>\n"; echo " </tr>\n"; // bugs if ($package['numbugs'] == 0) { $packageBugs = 'none'; } else { $packageBugs = $package['numbugs']; } $packageBugsLink = 'bugs/search.php?cmd=display&package_name[]=' . urlencode($package['name']); echo " <tr>\n"; echo " <th>Open Bugs:</th>\n"; echo " <td>"; echo "<a href=\"{$packageBugsLink}\">{$packageBugs}</a>"; echo "</td>\n"; echo " </tr>\n"; echo " </tbody>\n"; echo " </table>\n"; echo " </div>\n"; echo " </div>\n"; }