Login +

How To ? / Updating recordset

Suppose the Model of the table article generated:

public function action()
{    
    // Object
    $this->_generic->useModel("Article","main");
    $article = new Main_Article();
       
    // Get recordset with pk 1
    if ($article->getModel(1))
    {
        // Modify article_title
        $article->setArticleTitle("My first article updated");
           
        // If no errors, update
        $errors = $article->getErrors();
        if (empty($errors))        
            $updated = $article->save();
    }
}