Пример #1
0
 public function carrega()
 {
     $this->conectar();
     $query = "SELECT * FROM bandas ORDER BY nome ASC;";
     $resultado = $this->query($query);
     $this->desconectar();
     foreach ($resultado as $result) {
         $banda = new Banda();
         $banda->setId($result["id"]);
         $banda->setNome($result["nome"]);
         $this->conectar();
         $query = "SELECT count(*) as total FROM musicas WHERE id_banda=" . $result["id"] . ";";
         $total = $this->query($query);
         $this->desconectar();
         $banda->setNumMusicas($total[0]["total"]);
         $this->addBanda($banda);
     }
 }
Пример #2
0
 public function carrega($id)
 {
     $this->conectar();
     $query = "SELECT * FROM musicas WHERE id='" . $id . "';";
     $result = $this->query($query);
     $this->desconectar();
     $this->setId($result[0]["id"]);
     $this->setNome($result[0]["nome"]);
     $this->setDuracao($result[0]["duracao"]);
     $banda = new Banda();
     $banda->carrega($result[0]["id_banda"]);
     $this->setIdBanda($banda->getId());
     $this->setBanda($banda->getNome());
     $status = new Status();
     $status->carrega($result[0]["id_status"]);
     $this->setStatus($status);
     $editavel = false;
     if ($result[0]["id_status"] == "1") {
         $editavel = true;
     }
     $votos = new Votos();
     $votos->carrega($result[0]["id"], $editavel);
     $this->setVotos($votos);
     $recursos = new ListaRecursos();
     $recursos->carrega($result[0]["id"]);
     $this->setRecursos($recursos->getRecursos());
 }