Req #63884 [Wfx]: Add fetching methods

From: Date: Tue, 10 Jan 2023 17:17:22 +0000
Subject: Req #63884 [Wfx]: Add fetching methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243397@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63884&edit=1

 ID:                 63884
 User updated by:    vincent at lycoops dot be
 Reported by:        vincent at lycoops dot be
 Summary:            Add fetching methods
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            MySQLi related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I made this request 10 years ago...


Previous Comments:
------------------------------------------------------------------------
[2023-01-10 15:53:40] dharman@php.net

This is a very reasonable suggestion. It would make sense to have functions like this, which is
precisely why it was added in PDO. But this is mysqli... It wasn't designed to be easy to use.
It was designed to be as simple (from dev pov) as possible. It was also meant to be a thin veil over
the MySQL API. 

Thanks to mysqlnd, we were able to add some extra features. In PHP 8.2 we have a new method
execute_query() that returns mysqli_result. We also stopped supporting libmysql which was a major
limiting factor. You can rely on get_result being always present. With these improvements, I
don't think this proposal is needed anymore. 

You really should consider making a permanent switch to PDO as this is the true replacement for
mysql_* API. The mysqli extension has been improved enough that it can still be used in old
projects, but new projects shouldn't be using it anymore. PDO offers more functionality and is
much easier to use. 

If you think mysqli would benefit from this proposal nonetheless, please follow the RFC process.
This enhancement can be discussed on the mailing list.

------------------------------------------------------------------------
[2021-04-07 12:03:06] cmb@php.net

Where is the problem with calling $statement->get_result(), and
fetch from the result set?

Ah, I see, this method is only implemented for mysqlnd.

------------------------------------------------------------------------
[2013-01-02 13:04:17] vincent at lycoops dot be

Description:
------------
I think it'd be great if there were a method like PDO's PDOStatement::fetch($fetch_style)
method for mysqli_statement. Passing variables by reference is not always easy, espacially if you
don't know how many fields are being selected or if you want to manipulate some fields. 

I (and a lot of people) use PDO only because mysqli is missing this feature, which exists in
PDOStatement and mysqli_result.


I think the best way would be the following to be compatible with mysqli_result:
$statement->fetch_array(MYSQLI_ASSOC); (and all the other fetching methods)

Best regards
Vincent



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=63884&edit=1


Thread (4 messages)

« previous php.bugs (#243397) next »