1

I have a question regarding prepared statements using PDO.I have a query which selects all records from a table without any bind value i.e there are no filters.It is as simple as "SELECT * FROM EMP".The query would be exceuted a number of times as records are displayed using pagination.Is there any benefit using prepared sql statement or should I just stick to simple query statement?

Thanks for the help. Simmy

user2280352
  • 145
  • 11
  • this answer will shed some light about the performance point of view: http://stackoverflow.com/a/671802/1291428 – Sebas May 06 '13 at 19:00
  • @Sebas the linked article is almost a **decade** old – Your Common Sense May 06 '13 at 19:02
  • @YourCommonSense oh you're right he's talking about mysql 4.1 ... I'm going to see If I can find something else – Sebas May 06 '13 at 19:03
  • So, here we go: http://webdevrefinery.com/forums/topic/10380-database-extension-mysql-mysqli-pdo-benchmarks/ He's not talking about the cache though, it would deserve some delving. – Sebas May 06 '13 at 19:07

1 Answers1

3

Selecting all the records for pagination is an oxymoron.

If you are using pagination, it means you are selecting only certain page, a subset of records.
Selecting ALL records to display only part of them makes no sense. You have to select only records you are going yo show, using LIMIT operator.

And yes, you have to use prepared statements for LIMIT clause parameters in this case. Though there is some pitfall, explained here

Community
  • 1
  • 1
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345