3
I’m taking data from a form screen.
<?php
include_once '../model/dao/FitaDao.php';
include_once '../model/vo/FitaVO.php';
include_once '../model/vo/FilmeVO.php';
include_once '../model/vo/CategoriaFilmeVO.php';
include_once '../model/vo/ArtistaVO.php';
class FitaController {
public function insereFita(FitaVo $fita){
$fd = new FitaDao();
$fd->insereMidia($fita);
}
}
switch($_POST['acao']){
case 1:{
$categoria = new CategoriaFilmeVO($_POST['categoria']);
$artista = new ArtistaVO($_POST['artista'], $_POST['data']);
$filme = new FilmeVO($_POST['titulo'], $categoria);
$filme->adicionaArtistas($artista);
$fita = new FitaVO($_POST['formato'], $_POST['ano'], $filme);
$fc = new FitaController();
$fc->insereFita($fita);
break;
}
}
?>
So far so good, only when I call the class fitaDao
, he can’t find his way to class Conexao
.
<?php
require_once "../../conexao/Conexao.php";
include_once '../vo/CategoriaFilmeVO.php';
include_once '../vo/ArtistaVO.php';
include_once '../vo/FilmeVO.php';
include_once '../vo/FitaVO.php';
class FitaDao {
private $conexao;
function __construct(){
$conexao = new Conexao();
$this->conexao = $conexao->conectar();
$this->conexao->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
}
?>
Generating the error:
Warning: require_once(../../connected/Connected.php): failed to open stream: No such file or directory in C: xampp htdocs vintagelocadora app model dao Fitadao.php on line 2
Fatal error: require_once(): Failed Opening required '.. /.. /conexao/Conexao.php' (include_path='C: xampp php PEAR') in C: xampp htdocs vintagelocadora app model dao Fitadao.php on line 2
vlw guy was that same, thank you very much
– Rodrigo Jacinto
@Rodrigojacinto It’s okay to want
../../
, but trust me, it will cause you more difficulties of the similar.– Guilherme Nascimento
@Rodrigojacinto I find the solution presented by Guilherme more appropriate. My answer solves the problem directly but raises another question that may arise in the future if your class is reused, but okay, you choose the most appropriate answer to your problem.
– Filipe Moraes
@Guilhermenascimento then answer the god less headache Felipe to fix the code, but I see that yours will solve my future problems tbm, thank you
– Rodrigo Jacinto
@Rodrigojacinto excuse, can mark his, but the question of headache and goes from the limitation of knowledge (how much you already know) x understanding (what you understood from my explanation), this answer questionss shall assist you http://answall.com/q/60455/3635
– Guilherme Nascimento
@Guilhermenascimento All right thank you
– Rodrigo Jacinto