function liczbaProjektow() {
$id = $this->getRodzinaId();
$connection = Propel::getConnection();
$query = "
select count(distinct(projekt_id)) from projekt
left join projekt_has_czcionka using(projekt_id)
left join czcionka using(czcionka_id)
where czcionka_id in
(select czcionka_id from czcionka where rodzina_id = {$id})
";
$statement = $connection->prepare($query);
$statement->execute();
$result = $statement->fetch(PDO::FETCH_NUM);
return $result[0];
}
function ustalLiczbeProjektow() {
$this->setLiczbaprojektow($this->liczbaProjektow());
$this->save();
}
function ustalLiczbeCzcionek() {
$c = new Criteria();
$c->add(CzcionkaPeer::RODZINA_ID, $this->getRodzinaId());
$liczba_czcionek = CzcionkaPeer::doCount($c);
$this->setLiczbaczcionek($liczba_czcionek);
$this->save();
}
Listing 17.4. Metoda klasy Rodzina zliczająca czcionki i projekty
Rozdział 17. Widoki częściowe