2
Is there a problem with running multiple queries with the same PHP PDO code?
Example:
<?php
// Retorna $con
include 'conexao.php';
// Suponhamos que dbo.minha_tabela tenha apenas três campos, sendo um deles a chave-primária auto incrementável
$query = "update minha_tabela set coluna = 'valor_da_coluna' where coluna = 'condicao'; ";
$query .= "insert into minha_tabela values('valor_da_coluna', 'valor_da_coluna2'); ";
try{
$prepare = $con->prepare($query);
$prepare->execute();
echo json_encode(array('status' => '200 OK', 'message' => 'query executada com sucesso'));
} catch(\Exception $ex){
echo json_encode(
array(
'descrition' => $ex->getMessage(),
'code' => $ex->getCode()
)
);
}
Is there a proper way to execute multiple queries with the same command?
One of the problems is sql Injection (so by default only one query is sent), already imagined how to handle two result sets at the same time?
– rray
I’m using PDO with Prepared statements
– Not The Real Hemingway
I confused, who has this behavior (send only a query
mysqli_query()
, more than onemysqli_multi_query()
) is Mysqli. Has a related Soen– rray
That solves it. Thanks, @rray!!!
– Not The Real Hemingway