Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
willpoorman opened this issue Aug 8, 2017 · 1 comment

Comments

@willpoorman
Copy link

*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.

@willpoorman willpoorman changed the title DBUtil::create_database Function Appears to a return a Boolean instead of an Int DBUtil::create_database Function Appears to Return A Boolean Instead of An Int Aug 8, 2017
@WanWizard
Copy link
Member

That seems to be correct.

According to database/pdo/connection.php#L317, query() calls return true or false for queries of "undefined" type.

So the documenation isn't correct anymore, which is probably related to the introduction of the Schema class. I'll put a review on the todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants