$context->table(‚test‘)->limit() vrací poloviční počet výsledků než je limit

crassus
Backer | 78
+
0
-

Dobrý den,

narazil jsem na zvláštní problém při získávání dat z MemSQL. Následující kód vrací pouze poloviční počet výsledků než je limit. Když uvedu limit 10, vrátí to 5 výsledků. Když uvedu 100 vrátí to 50.

        $storage = new FileStorage(TEMP_PATH);
        $connection = new Connection('...');
        $structure = new Structure($connection, $storage);
        $conventions = new DiscoveredConventions($structure);
        $context = new Context($connection, $structure, $conventions, $storage);
        \Nette\Database\Helpers::createDebugPanel($connection, $explain = TRUE);

        $result = [];
        $i = 0;

        foreach($context->table('test')->limit(100) as $interaction)
        {
            $result[] = [
                'test' => $interaction['test'],
            ];
            $i++;
        }

        \Tracy\Debugger::barDump($result, $i);

Když použiji tento kód, tak to funguje správně:

        foreach($context->query($context->table('test')->limit(100)->getSql()) as $interaction)
        {
            $result[] = [
                'test' => $interaction['test'],
            ];
            $i++;
        }

Používám nette/database v2.4.9

Editoval crassus (10. 1. 2020 19:27)