Skip to content

DBUtil::create_database Function Appears to Return A Boolean Instead of An Int #743

@willpoorman

Description

@willpoorman

*Note I am using the PDO connection with a mariadb database, this may be different for other connection implementation types or database types.

The documentation states that the DBUtil::create_database function returns the number of rows affected. Yet it if you run it with if_not_exist set to true and a database that already exists, it still returns 1 instead of 0. If you run a create if not exists query in the mariadb shell on a database that already exists, it returns 0 rows affected.

Example query to test: run DBUtil::create_database('test'); twice.

Debug::dump( DBUtil::create_database('test') ); results in the dump saying that this is a boolean and not an integer.
is_bool( DBUtil::create_database('test') ); confirms it is a boolean as well.

Diving into the source code I followed it from DBUtil:create_database-> Database_Connection::schema->Schema::create_database->Database_Connection::query and then got lost in the PDO query implementation.

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