Skip to content

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

@tatswata

Description

@tatswata

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions