I'm having a problem inserting data into the database using the PDO and I do not know why, as I see everything seems to be right, follow the codes below.
Model class
class User {
private $id;
private $nome;
public setNome($nome){
$this->nome = $nome;
}
public getNome(){
return $this->nome;
}
}
DAO Class
class UsuarioDao implements Dao {
private $conexao;
function __construct(){
$connection = new Connection();
$this->conexao = $connection->getConnection();
}
public function insert($user){
try {
$query = "INSERT INTO usuarios(nome) VALUES(:nome)";
$this->conexao->prepare($query);
$this->conexao->bindValue(':nome',$user->getNome(),PDO::PARAM_STR);
return $this->conexao->execute();
}catch(PDOException $e){
echo $e->getMessage();
}
}
Class Instance
require_once('User.class.php');
require_once('UserDao.class.php');
class Teste {
$user = new User();
$user->setNome('Gabriel');
$userDao = new UserDao();
$userDao->insert($user);
}
About the error log no message appears, only the 500 error message.
And I'm getting the 500 error every time I run this code, I'd like someone to help me find the error in that code. I started learning PHP now I have more knowledge in JAVA taking advantage of the question do you know any framework ORM type Hibernate for PHP?