<?php

/**
 * Blank Model Class for Nooku Framework
 *
 * This is a blank model based off KModelTable. It has most of the
 * common methods when needing to create a new model. Just remove
 * the extra stuff you don't need, and set the values you do!
 *
 * @author	Jeremy Wilken <[email protected]>
 */
 
class ComComponentModelBlanks extends KModelTable
{
     /**
      * Class constructor
      */
     public function __construct(KConfig $config)
     {
	parent::__construct($config);

	// Add custom states. Default states are limit, offset, sort, direction, search
	//$this->_state->insert('title'    , 'string');
     }
	
     /**
      * Initializes settings, is first to be called in constructor
      */

     protected function _initialize(KConfig $config)
     {
	//$config->table = 'com.component.table.blanks';
	//$config->table_behaviors = array();

       	parent::_initialize($config);
    }

    /**
     * Method to get a item object which represents a table row
     *
     * @return KDatabaseRow
     */
    public function getItem()
    {
        return parent::getItem();
    }

    /**
     * Get a list of items which represnts a  table rowset
     *
     * @return KDatabaseRowset
     */
    public function getList()
    {
	return parent::getList();
    }

    /**
     * Get the total amount of items
     *
     * @return  int
     */
    public function getTotal()
    {
        return parent::getTotal();
    }

    /**
     * Builds SELECT columns list for the query
     */
    protected function _buildQueryColumns(KDatabaseQuery $query)
    {
	parent::_buildQueryColumns($query);
	//$query->select(array('tbl.*'));
    }

     /**
     * Builds FROM tables list for the query
     */
    protected function _buildQueryFrom(KDatabaseQuery $query)
    {
		parent::_buildQueryFrom($query);
      	$name = $this->getTable()->getName();
    	$query->from($name.' AS tbl');
    }

    /**
     * Builds LEFT JOINS clauses for the query
     */
    protected function _buildQueryJoins(KDatabaseQuery $query)
    {
	parent::_buildQueryJoins($query);
	//$query->join('LEFT', 'categories AS categories', 'categories.id = tbl.catid');
    }

    /**
     * Builds a WHERE clause for the query
     */
    protected function _buildQueryWhere(KDatabaseQuery $query)
    {
	parent::_buildQueryWhere($query);
	//if ($this->_state->state) $query->where('tbl.column', '=', 'value');
    }

     /**
     * Builds a GROUP BY clause for the query
     */
    protected function _buildQueryGroup(KDatabaseQuery $query)
    {
	parent::_buildQueryGroup($query);
    }

    /**
     * Builds a HAVING clause for the query
     */
    protected function _buildQueryHaving(KDatabaseQuery $query)
    {
	parent::_buildQueryHaving($query);
    }

    /**
     * Builds a generic ORDER BY clasue based on the model's state
     */
    protected function _buildQueryOrder(KDatabaseQuery $query)
    {
	parent::_buildQueryOrder($query);
    	//$query->order('state', 'DESC');
    }

    /**
     * Builds LIMIT clause for the query
     */
    protected function _buildQueryLimit(KDatabaseQuery $query)
    {
	parent::_buildQueryLimit($query);
	//if ($this->_state->state) $query->limit($this->_state->state, 'default');
    }
}