Actions

Source Code of This Project

/lib/model/DBuilder.php

<?php
/*
 * This file is part of the pwp package.
 * (c) 2009-2010 Victor Rad' <victor.v.rad[at]gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
*/

/**
 * Purpose of this class and his children, to create the chainlet of methods
 * for the building of flexible query in a database
 *
 * For example:
 * builderInstance
 *     ->filter->providers($request)
 *     ->filter->dateRange($request)
 *     ->reorganize($request)
 *     ->joinProvides()
 *     ->getQuery()->execute();
 *
 * @package    pwp
 * @subpackage DBuilder
 * @author     Victor Rad'
 */
abstract class DBuilder
{
    protected
        // instance of DBuilder_Query
        $query = null;

    public function __construct(DBuilder_Query $query)
    {
        // assign DBuilder_Query instance
        $this->query = $query;
    }

    public function __call($name,  $arguments)
    {
        if (method_exists($this->query, $name)){
            return $this->query->$name($arguments);
        }
    }

}