fuel/core

\ORM\Model::find() always returns empty array when using db config type: mysqli and enable_cache:false

Opened this issue · 0 comments

hi

when I set db config to type: mysqli and enable_cache:false,
\ORM\Model::find() always returns empty array.

like this:
fuel/app/config/db.php

return [
    'default' => [
        'type'          => 'mysqli',
        'connection'    => [
            'hostname'      => 'xxxxxx',
            'database'      => 'xxxxxx',
            'username'      => 'xxxxxx',
            'password'      => 'xxxxxx',
        ],
        'charset'       => 'utf8',
        'enable_cache'  => false,
    ]
];
<?php
class MyModel extends Orm\Model
{
    public static function get_instance()
    {
            $results = static::find('all', []);
            var_dump($results);exit;
     }
}

// array(0) {
// }

it works correctly when I set enable_cache to true.

maybe...
I think the cause of this problem is that second args of mysqli::query() is MYSQLI_USE_RESULT and any fetching method is not called (like mysqli_fetch_row()).

https://github.com/fuel/core/blob/1.8/master/classes/database/mysqli/connection.php#L283

using version:

fuel/core                          1.8.1              FuelPHP 1.x Core
fuel/oil                           1.8.1              FuelPHP 1.x Oil Package
fuel/orm                           1.8.1              FuelPHP 1.x ORM Package