[Solar-talk] Sql_Model insert not working!

Rodrigo Moraes rodrigo.moraes at gmail.com
Sat Apr 21 06:54:32 PDT 2007


Jeff,
I've noticed today that toArray() is not implemented in
Solar_Sql_Model. So $this->fetchNew()->toArray() will never work. How
we haven't noticed this?

As I'm working on data cache these days, I needed this method and then
I created a simple version:

    /**
     *
     * Returns a copy of the object data as an array.
     *
     * @return array
     *
     */
    public function toArray()
    {
        $this->_checkFocus('record');

        $data = array();

        foreach($this->_table_cols as $col_name => $spec) {
            $data[$col_name] = $this->$col_name;
        }

        return $data;
    }

It works for me and solves my problem. I hope I'm not missing anything.

rodrigo


More information about the solar-talk mailing list