par
chegmarco » 20 janv. 2021, 21:25
Bonsoir à tous.
S'il vous plaît j'aimerais transférer mes requêtes MySQLi qui comporte beaucoup de failles SQL. Ne comprenant pas encore très bien le concept
des requêtes préparée en PDO, je sollicite votre aide pour m'aider à corriger mon code ci-après
afin qu'il soit TOTALEMENT en requêtes préparées PDO:
Code : Tout sélectionner
//print_pdets.php
<?php
$ids = $_GET['ids'] ;
$parcels = $conn->query("SELECT * FROM parcels where id in ($ids) ");
$branch = array();
$branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches where id in (SELECT from_branch_id FROM parcels where id in ($ids) ) or id in (SELECT to_branch_id FROM parcels where id in ($ids) ) ");
while($row = $branches->fetch_assoc()):
$branch[$row['id']] = $row['address'];
endwhile;
while($row = $parcels->fetch_assoc()):
?>
//staff_list.php
<?php
$i = 1;
$qry = $conn->query("SELECT u.*,concat(u.firstname,' ',u.lastname) as name,concat(b.street,', ',b.city,', ',b.state,', ',b.zip_code,', ',b.country) as baddress FROM users u inner join branches b on b.id = u.branch_id where u.type = 2 order by concat(u.firstname,' ',u.lastname) asc ");
while($row= $qry->fetch_assoc()):
?>
//user_list.php
<?php
$i = 1;
$type = array('',"Admin","Registrar");
$qry = $conn->query("SELECT *,concat(lastname,', ',firstname,' ',middlename) as name FROM users order by concat(lastname,', ',firstname,' ',middlename) asc");
while($row= $qry->fetch_assoc()):
?>
//view_parcel.php
<?php
$qry = $conn->query("SELECT * FROM parcels where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$$k = $v;
}
$branch = array();
$branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches where id in ($to_branch_id,$from_branch_id)");
while($row = $branches->fetch_assoc()):
$branch[$row['id']] = $row['address'];
endwhile;
?>
//view_user.php
<?php
if(isset($_GET['id'])){
$type_arr = array('',"Admin","User");
$qry = $conn->query("SELECT *,concat(lastname,', ',firstname,' ',middlename) as name FROM users where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$$k = $v;
}
}
?>
AIDEZ-MOI S'IL VOUS PLAÎT A TRANSFORMER MON CODE EN
REQUÊTES PREPAREES PDO.
Merci d'avance.
Bonsoir à tous.
S'il vous plaît j'aimerais transférer mes requêtes MySQLi qui comporte beaucoup de failles SQL. Ne comprenant pas encore très bien le concept [b]des [u]requêtes préparée[/u] en PDO[/b], je sollicite votre aide pour m'aider à corriger mon code ci-après [b]afin qu'il soit TOTALEMENT en requêtes préparées PDO:[/b]
[code]//print_pdets.php
<?php
$ids = $_GET['ids'] ;
$parcels = $conn->query("SELECT * FROM parcels where id in ($ids) ");
$branch = array();
$branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches where id in (SELECT from_branch_id FROM parcels where id in ($ids) ) or id in (SELECT to_branch_id FROM parcels where id in ($ids) ) ");
while($row = $branches->fetch_assoc()):
$branch[$row['id']] = $row['address'];
endwhile;
while($row = $parcels->fetch_assoc()):
?>
//staff_list.php
<?php
$i = 1;
$qry = $conn->query("SELECT u.*,concat(u.firstname,' ',u.lastname) as name,concat(b.street,', ',b.city,', ',b.state,', ',b.zip_code,', ',b.country) as baddress FROM users u inner join branches b on b.id = u.branch_id where u.type = 2 order by concat(u.firstname,' ',u.lastname) asc ");
while($row= $qry->fetch_assoc()):
?>
//user_list.php
<?php
$i = 1;
$type = array('',"Admin","Registrar");
$qry = $conn->query("SELECT *,concat(lastname,', ',firstname,' ',middlename) as name FROM users order by concat(lastname,', ',firstname,' ',middlename) asc");
while($row= $qry->fetch_assoc()):
?>
//view_parcel.php
<?php
$qry = $conn->query("SELECT * FROM parcels where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$$k = $v;
}
$branch = array();
$branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches where id in ($to_branch_id,$from_branch_id)");
while($row = $branches->fetch_assoc()):
$branch[$row['id']] = $row['address'];
endwhile;
?>
//view_user.php
<?php
if(isset($_GET['id'])){
$type_arr = array('',"Admin","User");
$qry = $conn->query("SELECT *,concat(lastname,', ',firstname,' ',middlename) as name FROM users where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$$k = $v;
}
}
?>[/code]
AIDEZ-MOI S'IL VOUS PLAÎT A TRANSFORMER MON CODE EN [b]REQUÊTES PREPAREES PDO[/b].
Merci d'avance.