* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
+__autoload('xdb');
+
// {{{ class PlLimit
class PlLimit
{
const MODE_RIGHT = 'RIGHT';
const MODE_INNER = 'INNER';
- public function __construct($mode, $table, $condition)
+ private function __construct($mode, $params)
{
+ $table = array_shift($params);
+ $condition = call_user_func_array(array('XDB', 'format'), $params);
if ($mode != self::MODE_LEFT && $mode != self::MODE_RIGHT && $mode != self::MODE_INNER) {
Platal::page()->kill("Join mode error: unknown mode $mode");
return;
}
return $str;
}
+
+ /** Build a left join
+ * @param table The name of the table.
+ * @param condition The condition of the jointure
+ */
+ public static function left()
+ {
+ $params = func_get_args();
+ return new PlSqlJoin(self::MODE_LEFT, $params);
+ }
+
+ /** Build a right join
+ * @param table The name of the table.
+ * @param condition The condition of the jointure
+ */
+ public static function right()
+ {
+ $params = func_get_args();
+ return new PlSqlJoin(self::MODE_RIGHT, $params);
+ }
+
+ /** Build a inner join
+ * @param table The name of the table.
+ * @param condition The condition of the jointure
+ */
+ public static function inner()
+ {
+ $params = func_get_args();
+ return new PlSqlJoin(self::MODE_INNER, $params);
+ }
}
// }}}
public function toggleDesc()
{
- $this->desc = !$desc;
+ $this->desc = !$this->desc;
}
public function setDescending($desc = true)
public function __construct()
{
- $children = func_get_args();
- foreach ($children as &$child) {
- if (!is_null($child) && ($child instanceof PlFilterCondition)) {
- $this->addChild($child);
+ $this->addChildren(pl_flatten(func_get_args()));
+ }
+
+ public function addChildren(array $conds)
+ {
+ foreach ($conds as &$cond) {
+ if (!is_null($cond) && ($cond instanceof PlFilterCondition)) {
+ $this->addChild($cond);
}
}
}
* @param $objects The objects to filter
* @param $limit The portion of the matching objects to show
*/
- public abstract function filter(array $objects, PlLimit &$limit);
+ public abstract function filter(array $objects, $limit = null);
public abstract function setCondition(PlFilterCondition &$cond);
/** Get objects, selecting only those within a limit
* @param $limit The portion of the matching objects to select
*/
- public abstract function get(PlLimit &$limit);
+ public abstract function get($limit = null);
/** PRIVATE FUNCTIONS
*/
}
// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>