Skip to content

Conversation

jozefhornik
Copy link

SELECT WITH OFFSET is broken:

<?php
declare(strict_types=1);

include __DIR__.'/../vendor/autoload.php';

$pdo = new \Vimeo\MysqlEngine\Php8\FakePdo('mysql:dbname=depo;host=localhost', 'user', 'password');
$pdo->query('CREATE TABLE `test` (`id` INT NOT NULL) ENGINE=innodb DEFAULT CHARSET=utf8');
$pdo->query('INSERT INTO `test`(`id`) VALUES (1), (2)');

$stmt = $pdo->query('SELECT * FROM `test` LIMIT 10');
var_dump($stmt->fetch());
/*
Correct:
array(2) {
  ["id"]=>
  string(1) "1"
  [0]=>
  string(1) "1"
}
 */


$stmt = $pdo->query('SELECT * FROM `test` LIMIT 10 OFFSET 1');
var_dump($stmt->fetch());
/*
Expected:
array(2) {
  ["id"]=>
  string(1) "2"
  [0]=>
  string(1) "2"
}
Actual:
bool(false)
 */

I added a test and a fix for it.

@muglug muglug merged commit c2cf5e5 into vimeo:master Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants