I'm going crazy... I have two PHP class, one that define a Gallery (with method like "add_media, get_media...") and the class Media. All works fine, but if I do the new Media statement twice in the same time it breaks everything....
Here some code of my Classe
class Media {
private $id;
private $titolo;
private $alt;
private $src;
private $thumb;
private $modelli=array();
private $stato;
private $ordinamento=array();
function __construct($params) {
if(isset($params['id'])){
$this->id=$params['id'];
}
$this->titolo=$params['titolo'];
$this->alt=$params['alt'];
$this->src=$params['src'];
$this->thumb=$params['thumb'];
$this->modelli=$params['modelli'];
$this->stato=$params['stato'];
$this->ordinamento=$params['ordinamento'];
}
//function get media
function get_media($id){
$dbfile = __DIR__ . Galleria::DATABASE_LOCATION . Galleria::DATABASE_NAME . ".db";
// bind the database handler
$this->database = new db("sqlite:" . $dbfile);
$query="id = '".$id."'";
$results = $this->database->select(Galleria::DATABASE_NAME, $query);
return $results;
}
The Galleria object is created once, then I call on that object multiple get_media()
Probably is a mistake in the Media class definition...any suggestion?
Thanks!!!