FAQ
Edit report at https://bugs.php.net/bug.php?id=70949&edit=1

  ID: 70949
  Updated by: rasmus@php.net
  Reported by: s7g2vp2 at yahoo dot co dot uk
  Summary: SQL Statements With Limit And Offset Fail
  Status: Feedback
  Type: Bug
  Package: MySQLi related
  Operating System: Windows Server 2012
  PHP Version: 7.0.0RC7
  Block user comment: N
  Private report: N

  New Comment:

Are you getting a MySQL error? A common cause of this is that you are sending something than a positive integer as the offset. For example, if you are doing something like:

     $offset = ceil($page * 10);

$offset is now a float because ceil() always returns a float and the driver will pass that as something like "10.0" which will make offset fail. Make sure you cast any offsets you substitute into your query to an int first. eg.

     $offset = (int)ceil($page * 10);


Previous Comments:
------------------------------------------------------------------------
[2015-11-20 14:39:32] laruence@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------
[2015-11-20 11:10:42] s7g2vp2 at yahoo dot co dot uk

Description:
------------
While testing our app using PHP7RC7 we noticed some of the SQL statements failed to return a result set.

After some investigation it appears that the syntax LIMIT x OFFSET y causes a problem. The alternative syntax LIMIT y,x does appear to work.

We are using MySQLi driver and prepared statements. The LIMIT & OFFSET values are part of the statement and not bound.

All statements work in previous versions of PHP and also work in MySQL Workbench.



------------------------------------------------------------------------

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 9 | next ›
Discussion Overview
groupphp-bugs @
categoriesphp
postedNov 20, '15 at 11:10a
activeNov 27, '15 at 7:53a
posts9
users3
websitephp.net

People

Translate

site design / logo © 2017 Grokbase