Answers for "pdo fetch all row"

SQL
1

pdo fetchall as object

<?php
 $sth = $dbh->prepare("SELECT name, colour FROM fruit");
 $sth->execute();

 $result = $q->fetchAll(PDO::FETCH_OBJ);
 //$result contains an array of stdObjects
 ?>
Posted by: Guest on April-26-2021
0

sql fetch next 10 rows pdo

// You could have your values in variables (or hardcoded)
$offset = 0;
$limit = 5;

$statement = $pdo->prepare('SELECT * FROM livro ORDER BY id OFFSET :offset ROWS FETCH NEXT :limit ROWS ONLY');

// Next you need to bind the values
$statement->bindValue(':offset', (int) $offset, PDO::PARAM_INT); 
$statement->bindValue(':limit', (int) $limit, PDO::PARAM_INT); 

// Now execute your statement
$statement->execute();
Posted by: Guest on March-23-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language