Zend_Db_Table_Row already did it for you:
   $table = new MyApp_Db_Table;
   $data = $form->getValues();

   $row = $table->createRow($data);
   $row->save();
   // or
   $row = $table->createRow();
   $row->setFromArray($data);
   $row->save();

Mickael

PHPScriptor a écrit :
How I deal with this. I extend all my models with MyApp_Db_Table (this is
somewhere in my library directory). MyApp_Db_Table is extended by
Zend_Db_Table_Abstract.
With $this->_getCols(); I get all the columns in my table. If I have values
posted that are not in the table columns I remove them before inserted. You
only have to declare this ones and extend all your models with this class.

I hope this helped...

class MyApp_Db_Table extends Zend_Db_Table_Abstract
{
    function __construct()
    {
        parent::__construct();
    }

    public function insert($data)
    {
       $vars = $this->_getCols();
       $keys = array_keys($data);
       foreach($keys as $key)
       {
         if(!in_array($key, $vars))
                unset($data[$key]);
       }
       return parent::insert($data);
    }
}

Reply via email to