Hola a todos, me gustaría si estoy aplicando correctamente este patron en PHP ya que lo uso en java frecuentemente.
Interface DAO
Código:
<?php
interface NoticeDAO {
public function showAllNotice();
}
Implementacion del DAO
Código:
<?php
require_once "./sql/DBConnection.php";
require_once "./dao/NoticeDAO.php";
require_once "./dto/Notice.php";
class NoticeDAOImplement extends DBConnection implements NoticeDAO {
public function showAllNotice() {
# se realiza la consulta a la base de datos
$mysqli = $this->connect();
$result = $mysqli->query("SELECT * FROM notice");
$notice = new Notice();
while ($row = $result->fetch_assoc()) {
echo $notice->setNoticeId($row['notice_id']);
$notice->setNoticeId($row['notice_title']);
$notice->setNoticeId($row['notice_datetime']);
$notice->setNoticeId($row['notice_content']);
}
return $notice;
}
}
EL uso
Código:
<?php
include_once './impl/NoticeDAOImplement.php';
$noticeDao = new NoticeDAOImplement();
$notice = $noticeDao->showAllNotice();
echo "<br><br>=========>".$notice->getNoticeTitle();
?>
La pregunta es porque no me esta devolviendo ningún valor