Od jakiegos czasu sledze to co dzieje sie na tym subforum. Kupilem ksiazke i powoli ucze sie OOP. Mam w szkole projekt do zrobienia i rzucilem sie na gleboka wode (jak dla mnie) z tematem katalogu filmowego w OOP. Ehh nie moge juz zmienic tego wyboru. Mieszajac wiedze z ksiazek i tego forum "cos" pisze. Przedstawie wam krotko 3 klasy jakie napisalem i zalezy mi ta tym zeby ktos powiedzial czy zmierzam w dobra strone lub czy powinienem na problem spojrzec z innej lepszej strony
okrojona klasa DB
<?php function fetch_row($query_result) { if(!$array) { return false; } else { return $array; } } public function ask($query){ return $result; } ?>
Klasa Movie
<?php class Movie { private $id = null; private $title = null; private $premiere = null; // ... i wiecej nie bede na forum pisal wszystkich { // ... } public function set__($var,$val) { $this->$var = $val; } public function get__($var) { return $this->$var; } //- } ?>
Klasa MovieManager (ktora ma pobierac i zarazem wyswietlac info o filmioe liste itp wykorzystujac klase Templates)
<?php include('class.DB.php'); include('class.Movie.php'); //include('class.Templates.php'); class MovieManager { public $db; public $tpl; function __construct($db) { $this->db=$db; $this->tpl= new Templates; } public function getMovie($id) { $sql="SELECT * FROM db_movies WHERE id='".$id."' LIMIT 1"; $result = $this->db->ask($sql); while($row = $this->db->fetch_row($result)) { $row['id'] = $result['id']; $row['title'] = $result['mv_title']; $row['premiere'] = $result['mv_premiere']; // ... //return new Movie($row); $mve = new Movie($row); } return $mve; } public function getSevenMovies() { $sql="SELECT * FROM db_movies LIMIT 7"; $result = $this->db->ask($sql); while($Temp = $this->db->fetch_row($result)) { $row['id'] = $Temp['id']; $row['title'] = $Temp['mv_title']; $evts[] = new Movie($row); } return $evts; } public function printMovieDetails() { } public function printMoviesList() { $this->tpl->load('commingMovies'); $this->tpl->parse(); { $this->tpl->display(); // - nie widac textow z bazy } } //- } ?>
Prosze o ocene i pomoc ( jak wyswietlac elementy? )