5
I’ve always worked with ASP connections using ADODB and navigating the regressions that the query returned to me was not a problem because there were:
<%
rs.movenext //anda para proxima linha do retorno da query
rs.moveprevious //anda para linha anterior do retorno da query
rs.movefirst //anda para a primeira linha do retorno da query
rs.movelast //anda para a ultima linha do retorno da query
%>
more information about these commands here.
I’m having trouble navigating my PHP query records using PDO. I did not find anything that is equivalent to these commands mentioned above for example.
Let’s say I have one foreach
to go through a query, but within each loop I need to check if the next record is the last record to add some more information in this current loop... how to do?
<?php
$sql = "Select * From Tabela";
$sql = $db->prepare($sql_pai);
$sql->execute();
if($sql->rowCount() > 0){
foreach($sql as $rs){
echo $rs["nome"];
//VERIFICAR SE O PROXIMO É O ULTIMO PARA ADICIONAR MAIS INFO
}
}
?>
In the
PDO
has thelastInsertId()
see -> http://php.net/manual/en/pdo.lastinsertid.php– MeuChapeu