Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Application_Model_Noticias extends Application_Model_Abstract
- {
- protected static $_dbTable_class = 'Application_Model_DbTable_Noticias';
- public function __construct()
- {
- $options['dbTable'] = Application_Model_Noticias::$_dbTable_class;
- parent::__construct($options);
- $this->_campos = $this->_dbTable->info(Zend_Db_Table::COLS);
- return $this;
- }
- public static function save( $params )
- {
- $validate = self::validate( $params ) ;
- if( $validate === true ):
- try
- {
- $dbTable = new self::$_dbTable_class;
- $row = $dbTable->createRow( $params );
- $return = $row->save();
- return $return;
- } catch (Exception $e)
- {
- throw new Exception( $e->getMessage(), $e->getCode() );
- die();
- }
- else:
- return $validate;
- endif;
- }
- protected static function validate( $params )
- {
- $form = new Teaser_Forms_Noticias();
- if (!$form->isValid( $params )):
- $messages = $form->getMessages();
- $return['type'] = 'error';
- $return['messagesError'] = $form->addErrorMessages( $messages );
- return $return;
- endif;
- return true;
- }
- }
Add Comment
Please, Sign In to add comment