Created
June 30, 2019 20:33
-
-
Save celsowm/da6b7ca9daa5059e624c9e594a6d7f04 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
include 'conexao.php'; | |
$filtro = ["preco_minimo" => "1.98"]; | |
$edicoes = [1,2,10]; | |
$edicoes = array_combine( | |
array_map(function($i){ return ':id'.$i; }, array_keys($edicoes)), | |
$edicoes | |
); | |
$in_placeholders = implode(',', array_keys($edicoes)); | |
$sql = "SELECT * FROM livro WHERE preco >= :preco_minimo AND edicao IN ($in_placeholders)"; | |
$statement = $pdo->prepare($sql); | |
$statement->execute(array_merge($filtro,$edicoes)); | |
foreach($statement as $livro){ | |
echo $livro['titulo']."</br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment