I do not quite understand PHP, but I'm trying to create a PDO connection. The connection works fine but does not enter the values ...
follow the code:
config
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "root");
define("DB_NAME", "everton");
define("DB_DSN_MYSQL", 'mysql:host='.DB_HOST.';dbname='.DB_NAME);
define("DB_DSN_FIREBIRD", 'firebird:host='.DB_HOST.';dbname='.DB_NAME);
date_default_timezone_set("America/Sao_Paulo");
connection
try {
$this->con = new PDO(DB_DSN_MYSQL, DB_USER, DB_PASSWORD);
} catch (PDOException $exception){
$flag['flag'] = 'CONN_FAILED';
die(json_encode($flag));
}
insertion
$sql = 'INSERT INTO teste (codigo, nome) VALUES (:codigo, :nome)';
$stmt = $this->con->prepare($sql);
$codigo = 1;
$nome = 'teste';
$stmt->bindValue(':codigo', $codigo);
$stmt->bindValue(':nome', $nome);