Skip to content

DB::select() doesn't use readonly instance basically... #2062

@ysshir

Description

@ysshir

DB::select() used to return Database_Query_Builder_Select class without connection before,
but now it returns with connection.
And the connection is created by \Database_Connection::instance() method.

\Database_Connection::instance() is defined as

public static function instance($name = null, array $config = null, $writable = true)

so the connection is always master one.

Actually I can use readonly instances in some ways like below.

  1. pass arguments to the execute method

    DB::select()->...->execute('default')

  2. set the static $_connection field of Model_Crud

    protected static $_connection = 'default';

but I think it should use readonly instances, when it is select query.
so I suggest to change the DB::select() method like below

public static function select($args = null) {
    return \Database_Connection::instance(null, null, false)->select(func_get_args());
}

any idea ??
thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions