From: Raphaël Barrois Date: Thu, 4 Feb 2010 20:38:43 +0000 (+0100) Subject: Minor bugfixes X-Git-Tag: core/1.1.0~90 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4aa4899becf6d5b8b0e16bd4f087d4ca4cb23b25;p=platal.git Minor bugfixes Signed-off-by: Raphaël Barrois --- diff --git a/classes/plfilter.php b/classes/plfilter.php index ed0e039..15bcaf5 100644 --- a/classes/plfilter.php +++ b/classes/plfilter.php @@ -32,7 +32,7 @@ class PlLimit public function getSql() { - if (!is_null($this->count)) { + if (!is_null($this->count) && $this->count != 0) { if (!is_null($this->from) && $this->from != 0) { return XDB::format('LIMIT {?}, {?}', (int)$this->from, (int)$this->count); } else { @@ -56,7 +56,7 @@ class PlSqlJoin public function __construct($mode, $table, $condition) { if ($mode != self::MODE_LEFT && $mode != self::MODE_RIGHT && $mode != self::MODE_INNER) { - Platal::page()->kill("Join mode error : unknown mode $mode"); + Platal::page()->kill("Join mode error: unknown mode $mode"); return; } $this->mode = $mode; @@ -98,7 +98,7 @@ class PlSqlJoin { $str = ''; foreach ($joins as $key => $join) { - if (! ($join instanceof PlSqlJoin)) { + if (!($join instanceof PlSqlJoin)) { Platal::page()->kill("Error: not a join: $join"); } $mode = $join->mode(); @@ -145,7 +145,7 @@ abstract class PlFilterOrder return $sel; } -// abstract protected function getSortTokens(&$pf); + abstract protected function getSortTokens(&$pf); } // {{{ interface PlFilterCondition diff --git a/classes/plset.php b/classes/plset.php index 93afc3f..5b0ecb6 100644 --- a/classes/plset.php +++ b/classes/plset.php @@ -24,6 +24,8 @@ */ abstract class PlSet { + const DEFAULT_MAX_RES = 20; + private $conds = null; private $orders = null; private $limit = null; @@ -44,7 +46,7 @@ abstract class PlSet } if ($orders instanceof PlFilterOrder) { - $this->orders = array($order); + $this->orders[] = $order; } else { foreach ($orders as $order) { $this->orders[] = $order; @@ -89,7 +91,7 @@ abstract class PlSet $pf = $this->buildFilter($this->conds, $this->orders); if (is_null($limit)) { - $limit = new PlLimit(20, 0); + $limit = new PlLimit(self::DEFAULT_MAX_RES, 0); } $it = $pf->get($limit); $this->count = $pf->getTotalCount(); @@ -192,13 +194,13 @@ class PlViewOrder */ public function __construct($name, PlFilterOrder &$pfo, $displaytext = null) { - $this->name = $name; + $this->name = $name; if (is_null($displaytext)) { $this->displaytext = ucfirst($name); } else { - $this->displaytext = $displaytext; + $this->displaytext = $displaytext; } - $this->pfo = $pfo; + $this->pfo = $pfo; } }