$sql="insert into actor (first_name,last_name) values (:first_name,:last_name)"; $parametros=[ 'first_name'=>'Perico', 'last_name'=>'De los palotes' ]; $st=$conn->prepare($sql); $st->execute($parametros);
$sql="SELECT city FROM country join city using(country_id) where country=:country"; $parametros=[ 'country'=>'Argentina' ]; $st=$conn->prepare($sql); $st->execute($parametros); $ciudades=$st->fetchAll(); print_r($ciudades);
$sql="SELECT country FROM country where country like :country"; $parametros=[ 'country'=>'%ar%' ]; $st=$conn->prepare($sql); $st->execute($parametros); $paises=$st->fetchAll(); print_r($paises);
$sql = "SELECT * FROM customer join address using(address_id) where email=:email and phone=:phone"; $parametros=[ 'email'=>'mary.smith@sakilacustomer.org', 'phone'=>'28303384290' ]; $st=$conn->prepare($sql); $st->execute($parametros); $cliente=$st->fetch(); if (empty($cliente)){ echo "No sé quién eres"; } else{ echo "hola ".$cliente['first_name']; }
$sql="update film set replacement_cost=replacement_cost*:descuento where rating=:rating"; $parametros=[ 'descuento'=>0.9, 'rating'=>'R' ]; $st=$conn->prepare($sql); $st->execute($parametros);