sql fetch next 10 rows pdo

Solutions on MaxInterview for sql fetch next 10 rows pdo by the best coders in the world

showing results for - "sql fetch next 10 rows pdo"
Philipp
21 Jul 2017
1// You could have your values in variables (or hardcoded)
2$offset = 0;
3$limit = 5;
4
5$statement = $pdo->prepare('SELECT * FROM livro ORDER BY id OFFSET :offset ROWS FETCH NEXT :limit ROWS ONLY');
6
7// Next you need to bind the values
8$statement->bindValue(':offset', (int) $offset, PDO::PARAM_INT); 
9$statement->bindValue(':limit', (int) $limit, PDO::PARAM_INT); 
10
11// Now execute your statement
12$statement->execute();
13