I'm having trouble inserting a date into the database with PDO. I have a mirror class on my table in the bank:
class PaginaEntity {
private $id;
private $data;
public function __construct(){
$this->data = date('d-m-y h:i:s A');
//gets and sethers
The class to insert:
class PaginaDao {
public function inserirPagina(PaginaEntity $paginaEntity) {
$conexao = new PDOUtil();
$insert = $conexao->getStance()->prepare("INSERT INTO tabela_teste(data) VALUES(:data)");
$insert->bindValue(":data", $paginaEntity->getData());
$insert->execute();
}
}
And I have the test form:
include_once '../entity/PaginaEntity.php';
include_once '../dao/PaginaDao.php';
include_once '../configs/PDOUtil.php';
if(isset($_GET["acao"])) {
$id = $_POST["id"];
$pagina = new PaginaEntity();
$daoPagina = new PaginaDao();
$daoPagina->inserirPagina($pagina);
}
?>
<form method="post" action="testeInsercaoPagina.php?acao=ok">
<label for="id">id da categoria</label>
<input type="text" name="id"> <br/><br/>
<button type="submit">Gravar</button>
</form>
What happens is the following error: