3 abstract class AccountTable extends DatabaseTable {
4 protected $valuecolumn;
6 public function __construct($table, $id)
8 parent::__construct($table, $id);
11 public function sum($blzkto)
13 $sql = sprintf("SELECT sum(%s) FROM %s WHERE blz_kto = %s",
16 $this->db->quote($blzkto));
17 return $this->db->fetchValue($sql);
20 public function distinctYears($blzkto)
22 $sql = sprintf("SELECT DISTINCT substr(datum::text,0,5) AS year FROM %s ".
23 "WHERE blz_kto = %s ORDER BY year DESC",
24 $this->table, $this->db->quote($blzkto));
25 return $this->db->fetchObjectList($sql);
28 public function distinctCategories($blzkto)
30 $sql = sprintf("SELECT DISTINCT category FROM %s WHERE blz_kto = %s ORDER BY category",
31 $this->table, $this->db->quote($blzkto));
32 return $this->db->fetchObjectList($sql);
35 public function distinctFromTo($blzkto, $period=false)
37 $sql = sprintf("SELECT DISTINCT from_to FROM %s WHERE blz_kto = %s%s ORDER BY from_to",
38 $this->table, $this->db->quote($blzkto),
39 $period === false ? '' : ' AND ' . $period);
40 return $this->db->fetchObjectList($sql);
43 public function distinctStatements($blzkto)
45 $sql = sprintf("SELECT DISTINCT statement FROM %s WHERE blz_kto = %s ORDER BY statement DESC",
46 $this->table, $this->db->quote($blzkto));
47 return $this->db->fetchObjectList($sql);