-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #704 from nilsonLazarin/equipeCefet240911
Equipe cefet240911
- Loading branch information
Showing
21 changed files
with
581 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
<?php | ||
require_once'../Conexao.php'; | ||
$pdo = Conexao::connect(); | ||
|
||
$sql = 'select * from pet_especie'; | ||
$stmt = $pdo->query($sql); | ||
$resultado = array(); | ||
while ($row = $stmt->fetch()) { | ||
$resultado[] = array('id_especie'=>$row['id_pet_especie'],'especie'=>$row['descricao']); | ||
} | ||
echo json_encode($resultado); | ||
|
||
?> | ||
<?php | ||
require_once '../Conexao.php'; | ||
|
||
try { | ||
// Conectar ao banco de dados | ||
$pdo = Conexao::connect(); | ||
|
||
// Consulta SQL | ||
$sql = 'SELECT id_pet_especie, descricao FROM pet_especie'; | ||
|
||
// Preparar e executar a consulta | ||
$stmt = $pdo->query($sql); | ||
|
||
// Array para armazenar os resultados | ||
$resultado = array(); | ||
|
||
// Fetch os resultados e sanitizar os dados | ||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { | ||
$id_especie = htmlspecialchars($row['id_pet_especie'], ENT_QUOTES, 'UTF-8'); | ||
$especie = htmlspecialchars($row['descricao'], ENT_QUOTES, 'UTF-8'); | ||
|
||
$resultado[] = array('id_especie' => $id_especie, 'especie' => $especie); | ||
} | ||
|
||
// Retornar os resultados em formato JSON | ||
header('Content-Type: application/json'); | ||
echo json_encode($resultado); | ||
|
||
} catch (PDOException $e) { | ||
// Tratamento de erros de conexão | ||
echo json_encode(array('error' => 'Erro ao conectar ao banco de dados: ' . $e->getMessage())); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.