Login +

How To ? / Inserting recordset

Suppose the Model of the table article generated:

public function action()
{    
    // Object
    $this->_generic->useModel("Article","main");
    $article = new Main_Article();
       
    // Call specific setters
    $article->setArticleTitle("My first article");
    $article->setArticleContent("<p>Article content in HTML</p>");
    $article->setArticleDate(date("Y-m-d H:i:s"));
       
    // If no errors, insert article
    $errors = $article->getErrors();
    if (empty($errors))        
        $article_id = $article->create();
}