I did a lot of research, but I do not know how to apply.
I did a lot of research, but I do not know how to apply.
See an example of how to enter a neighborhood:
public function insert (Bairro $bairro){
$this->connection = null;
$teste = 0;
$this->connection = new ConnectionFactory();
$this->connection->beginTransaction();
try{
$query = "INSERT INTO bairro
(CD_BAIRRO, NM_BAIRRO, CD_CIDADE)
VALUES
(NULL, :bairro, :cidade)";
$stmt = $this->connection->prepare($query);
$stmt->bindValue(":bairro", $bairro->getNmBairro(), PDO::PARAM_STR);
$stmt->bindValue(":cidade",$bairro->getCidade()->getCdCidade(), PDO::PARAM_INT);
$stmt->execute();
$teste = $this->connection->lastInsertId();
$this->connection->commit();
$this->connection = null;
}catch(PDOException $exception){
echo "Erro: ".$exception->getMessage();
}
return $teste;
}
I hope it helps to have a notion