go to bug id or search bugs for
PostgreSQL extension should return native PHP types (int, bool, string) from database queries as pdo_pgsql does.
To maintain backward compatibility, we can add a new result type flag to pg_fetch_array and pg_fetch_all (e.g. PSQL_TYPED) or create new fetch function.
Add a Patch
Add a Pull Request
Added pull request for the first variant:
it's simply wrong add a param to each and every function and just to two can't be serious - how do you imagine to port existing code to that without a ton of errors over the time?
besides that another quick shot with mor incosntistences given that myqli has solved that years ago ina proper way
if(mysqli_options($this->conn, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, TRUE) === FALSE)
fgfgfgfdf, what about pg_fetch_result? It returns false on an error and will, in your case, return false also if it succeeds in getting the value false.
didn't you get the point?
it has to be *connection wide* option and it shouldn't be completly different for each and every database type
mysqli_init() -> mysqli_options() -> mysqli_real_connect()
This extension do not have any connection wide options.
The problem with pg_fetch_result is that it cannot return false as valid result because it return false is case of an error.
Of course I understand that. I don't think you understand what I mean.
Now pg_fetch_result returns FALSE on the error. If they do as you suggest, it will return FALSE on the error and FALSE if it need to return the boolean value of FALSE, which came from the database.
> This extension do not have any connection wide options
cool, than introduce pg_options() is the right thing to do for the sake of cosistency and usability
either i have a strict typed project or not and seek and adjust every single line containing pg_ don't scale at any moment, in a existing codebase nobody would do that and later you can be sure people forget to use the option here and there which is not funny when you get strings instead int on random places
MySQL does not have a Boolean type, and Postgres does.
PostgreSQL have bool type:
$res = pg_query($db, "SELECT false");
This code should print "bool(false)" in native types mode but
"FALSE is returned if row exceeds the number of rows in the set, or on any other error."
> MySQL does not have a Boolean type, and Postgres does
and how is that relevant when it's about a global connection option versus add params to each and every single command which needs massive rewrite in existing userland code to use it?
We can add extension wide (php.ini) option to change behavior of all fetch functions, also we can add fourth param to pg_fetch_result to return error in it for example.
> We can add extension wide (php.ini) option to change
> behavior of all fetch functions
you can't, no RFC introducing ini options which change language behavior that way will pass in 2019
> also we can add fourth param to pg_fetch_result to return
> error in it for example
or you can refrain from half thougth solutions and write a proper RFC which get discussed, no way that any change in that context will go into 7.2/7.3/7.4 anyways
> and how is that relevant when it's about a global connection option versus add params to each and every single command which needs massive rewrite in existing userland code to use it?
Because the global option will also affect this function too. It is absolutely unclear how it should work in this case.