[Solar-talk] Small model ideas

Rodrigo Moraes rodrigo.moraes at gmail.com
Tue Sep 26 05:45:25 PDT 2006


I've setup Solar 0.24 to play with a new model try that takes full
advantage of Solar_Sql Row & Rowset.

- Idea 1
One of the disadvantages of using a "pure" Solar_Sql_Table approach is
the waste of resources selecting all columns in a table, when many
times you just need some columns. One simple idea that came up to
still use the Table power but saving resources is to restrict the
selected columns before fetching. In a base class that extends
Solar_Sql_Table, I've added this method:

    // pass an array of cols you will need in the select
    public function selectCols($cols)
    {
        $selected = array();
        foreach($cols as $col) {
            $selected[$col] = $this->_col[$col];
        }
        $this->_col = $selected;
    }

It is called before fetching, setting the columns that will be
selected. It's simple enough, but I would like to register this need
and ask for feeddback and more ideas. I want to start collecting other
simple solution for models (the wiki and SVN accounts will help us to
start projects and brainstorms in many directions, I hope :-).

cheers,
rodrigo


More information about the solar-talk mailing list