Skip to content

Conversation

jozefhornik
Copy link

@jozefhornik jozefhornik commented Jul 10, 2024

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.

@@ -1,5 +1,5 @@
{
"name": "vimeo/php-mysql-engine",
"name": "jozefhornik/php-mysql-engine",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you mean to change the name

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