fuel / docs

Fuel PHP Framework - Fuel v1.x documentation
http://fuelphp.com/docs
Other
166 stars 233 forks source link

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

Open willpoorman opened 6 years ago

willpoorman commented 6 years ago

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

WanWizard commented 6 years ago

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.