W ramach nauki obiektówki postanowiłem wykonać jakiś mały projekt, aby załapać podstawy. Po krótkim namyśle stwierdziłem, że napiszę sobie bloga.
I teraz mam do was, bardziej doświadczonych, pytanie. Czy idę w dobrą stronę podczas skrobania tego projektu? Co robię źle, a co dobrze (o ile coś

Poniżej przedstawiam to co napisałem do tej pory. Co prawda nie ma tego wiele. Głównie chodzi mi tutaj o klasę content.php oraz wpisy.php.
index.php
<?php include_once('class/class.db.php'); include_once('header.php'); include_once('content.php'); include_once('footer.php'); $db = new db("mysql:host=localhost;dbname=blog;", "root", ""); $db->query('SET NAMES utf8'); $content = new Content($db); $content->getSection(); $footer = new Footer; ?>
header.php
<?php public function __construct($tytul){ $this->tytul = $tytul; } public function getHeader(){ return ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/popup.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="js/jquery-impromptu.js"></script> <title>'.$this->tytul.'</title> <script type="text/javascript"> function popup(zmienna){ $.prompt(zmienna,{ overlayspeed: 2, buttons: {}}); } </script> </head> <body> '; } } ?>
footer.php
<?php class Footer{ public function getFooter(){ return ' <div id="footer"> <span class="footer">Created by Kamil</span> </div> </body> </html>'; } } ?>
content.php
<?php include_once('class/wpisy.php'); class Content{ public $cont; private $db; public function __construct($db){ $this->db = $db; } public function getSection(){ switch($_GET['section']) { case 'show' : $this->cont = new Wpisy($this->db); $this->cont->show(); break; default: $this->cont = new Wpisy($this->db); $this->cont->error404(); } switch($_GET['action']) { case 'add' : $this->cont = new Wpisy($this->db); $this->cont->addComent($_POST); break; } } else { $this->cont = new Wpisy($this->db); $this->cont->show(); } } } ?>
wpisy.php
<?php class Wpisy{ private $db; public function __construct($db){ $this->db = $db; } public function show(){ $result = $this->db->select('wpisy', '1=1 ORDER BY data_dodania desc', '', 'id, temat, tresc, DATE_FORMAT(data_dodania, \'%d.%m.%Y\') AS data_dodania'); foreach($result as $record){ echo ' <div class="wpis"> <h6>'.$record['temat'].'</h6> <span class="data">'.$record['data_dodania'].' » Kamil</span> <div class="tresc">'.$record['tresc'].'</div> <div class="wiecej"> <a href="index.php?section=show¶m='.$record['id'].'" class="wiecej clear">Czytaj całość</a> </div> </div> '; } } else { $result = $this->db->select('wpisy', 'id='.$_GET['param'], '', 'id, temat, tresc, DATE_FORMAT(data_dodania, \'%d.%m.%Y\') AS data_dodania'); foreach($result as $record){ echo ' <div class="wpis"> <h6>'.$record['temat'].'</h6> <span class="data">'.$record['data_dodania'].' » Kamil</span> <div class="tresc">'.$record['tresc'].'</div> <div class="wiecej"> <a href="index.php?section=show" class="wiecej clear">Wróć</a> </div> </div> '; } $result = $this->db->select('komentarze k, wpisy w', 'id_wpisu='.$_GET['param'].' and w.id=k.id_wpisu', '', 'k.id kid, nick, k.tresc ktresc, k.temat ktemat, DATE_FORMAT(k.data_dodania, \'%d.%m.%Y %h:%i:%s\') AS kdata_dodania'); foreach($result as $record2){ echo $record2['kid'].' - '.$record2['nick'].' - '.$record2['ktemat'].' - '.$record2['ktresc'].' - '.$record2['kdata_dodania'].'<br /><br />'; } echo ' <form action="index.php?section=show&action=add¶m='.$_GET['param'].'" method="post"> <fieldset class="komentarze"> <label for="nick">Nick<br /><input type="text" name="nick" id="nick" value="" /></label> <label for="temat">Temat <span class="wymagane">*</span><br /><input type="text" name="temat" id="temat" value="Re: '.$record['temat'].'" /></label> <label for="tresc">Treść <span class="wymagane">*</span><br /><textarea name="tresc" id="tresc"></textarea></label> <label for="dodaj"><input type="submit" name="dodaj" id="dodaj" value="Dodaj komentarz" /></label> </fieldset> </form> '; } } public function addComent($array){ $array['id_wpisu'] = $_GET['param']; $result = $this->db->insert('komentarze', $array); if($result){ } else { } } } public function error404(){ } } ?>