From: ETd <et...@us...> - 2004-10-08 16:10:26
|
Update of /cvsroot/openbash-org/openbash-org/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3682 Added Files: Error.php NewsManager.php Log Message: Error: no sé muy bien como vamos a hacer el Error-handling NewsManager: Gestion de noticias --- NEW FILE: Error.php --- <? /* * Error.php * 8 / OCT / 2004 * author: etd <et...@no...> * */ class Error { var $msg; function Error( $pErrorMsg ) { $this->$msg; } function getMessage() { return $this->msg; } } ?> --- NEW FILE: NewsManager.php --- <?php /* vim: set sts=2 ts=8 sw=2 noexpandtab: */ /* * NewsManager.php * 8 / OCT / 2004 * author: etd <et...@no...> * * based on etdDBClass by etd. this class is used to manage (add/del/modify/list) * the news stored on 'news' dbTable. * */ require_once( "etdDBContainer.php" ); require_once( "News.php" ); class NewsManager extends etdDBContainer { /* * class constructor, needs some DB options see * etdDBContainer for Details */ function NewsManager( $dbOptions ) { return $this->etdDBContainer( $dbOptions ); } /* * getNews() .- return an array of News elements with * all the different news from the DB */ function getNews() { $result = $this->getRows(); if ( get_class($result) == 'error' ) { return new Error( 'Error al recuperar los contenidos de la base de datos.'.$result->getMessage() ); } foreach( $result as $noticia ) { $tmp[] = new News($noticia['id'], $noticia['author'], $noticia['datetime'], $noticia['title'], $noticia['body'] ); } return $tmp; } /* * addNew() */ function addNew($pAuthor, $pDayTime, $pTitle, $pBody) { $id = rand(5, 15); $tmpA = array ( $id, $pAuthor, $pDayTime, $pTitle, $pBody ); $result = $this->addRow( $tmpA ); if (get_class($result) == 'error' ) { return new Error( 'Error al añadir la noticia: '.$result->getMessage() ); } return true; } /* * delNew() */ function delNew() { } } ?> |