Parašė Narysx· 2008 Gru. 14 15:12:52
#1
public function gamesCount() {
$sql = "SELECT count(*) as count
FROM ".TABLE_GAMES;
$count = $this->db->getOne($sql);
return $count;
}
Kas blogai šitoje funkcijoje? Jei ką, va visų funkcijų failas:
<?php
class Results {
public function __construct() {
$this->db = $GLOBALS["db"];
}
public function getAll() {
$sql = "SELECT ga_id, ga_date, ga_home_score, ga_away_score, ga_home_id, h.te_city as ho, ga_away_id, a.te_city as aw
FROM ".TABLE_GAMES.", ".TABLE_TEAMS." as h, ".TABLE_TEAMS." as a WHERE ga_home_id=h.te_id AND ga_away_id=a.te_id
ORDER BY ga_date DESC";
$results = $this->db->getAll($sql);
return $results;
}
public function getByDay($date = NULL) {
if ($date == NULL) {
$date = strtotime(date("Y-m-d", time()));
} else {
$date = strtotime(date("Y-m-d", $date));
}
$from = $date;
$to = $date + (60*60*24);
$sql = "SELECT ga_id, ga_date, ga_home_score, ga_away_score, ga_home_id, h.te_city as ho, ga_away_id, a.te_city as aw
FROM ".TABLE_GAMES.", ".TABLE_TEAMS." as h, ".TABLE_TEAMS." as a
WHERE ga_home_id=h.te_id AND ga_away_id=a.te_id AND
ga_date >= $from AND ga_date < $to
ORDER BY ga_date ASC";
$results = $this->db->getAll($sql);
return $results;
}
public function getDays() {
$sql = "SELECT count(*) as count, DATE_FORMAT(FROM_UNIXTIME(ga_date), '%Y-%m-%d') AS date, ga_date
FROM ".TABLE_GAMES."
GROUP BY date
ORDER BY ga_date ASC";
$days = $this->db->getAll($sql);
return $days;
}
public function gamesCount() {
$sql = "SELECT count(*) as count
FROM ".TABLE_GAMES;
$count = $this->db->getOne($sql);
return $count;
}
}
?>
Redagavo Narysx· 2008 Gru. 14 15:12:09