[Solar-talk] Restricting selected cols in Solar_Sql_Table

Rodrigo Moraes rodrigo.moraes at gmail.com
Mon Jan 15 11:45:40 PST 2007


Hi all,
I always wondered about this, so let's see what you think: I miss a
mechanism to optionally restrict the returned cols in Solar_Sql_Table.
The fetch* methods are pretty handy, and sometimes you have a table
already built but need just a few cols... Here's an idea: set the cols
you want in $_select_col:

    protected $_select_col;

    public function select(...)
    {
        ...

        // If the cols are not defined, use the default behaviour.
        if(!$this->_select_col) {
            $this->_select_col = array_keys($this->_col);
        }

        $select = $this->_newSelect();
        $result = $select->from($this->_name, $this->_select_col)

        ...

        $this->_select_col = null;

        ...
    }

Bad idea?

rodrigo


More information about the solar-talk mailing list