Re: [PHP-DEV] mysqli_fetch_all(MYSQLI_OBJECT)

On Sunday, 23 February 2025 at 03:09:38 GMT, Kamil Tekiela tekiela246@gmail.com wrote:

Hi,

Could you share the implementation?

Regards,
Kamil

Hi Kamil

Thank you for your interest. I appreciated your prior work on mysqli such as the default error mode change.

https://github.com/ecvej/php-src/tree/mysqli-fetch-all-objects

Please note that this is the first time I have programmed in c. That was fine by itself, the difficulty I found was the extensive use of macros in the php-src was a steep climb for someone learning the language at the same time as learning the codebase.

Please note that I may be slow to reply during the forthcoming week.

PS first attempt at bottom posting - hopefully works

Gareth

On Sunday, 23 February 2025 at 02:57:07 GMT, Gareth Peters wrote:

Hi all

I’ve written code to expand the functionality of mysqli_fetch_all. It allows you to fetch all results as objects rather than just arrays. It has the same features as fetch_object, such as being able to specify the name of a class to instantiate and being able to pass in an array of constructor arguments.

Is this feature likely to be of wider interest? If yes I can set aside time to work on an RFC.

Gareth


On Sunday, 23 February 2025 at 03:09:38 GMT, Kamil Tekiela wrote:

Hi,

Could you share the implementation?

Regards,
Kamil


On Sunday, 23 February 2025 at 02:57:07 GMT, Gareth Peters wrote:

Hi Kamil

https://github.com/ecvej/php-src/tree/mysqli-fetch-all-objects

Gareth


Hi Kamil et al - did you have an thoughts on whether this feature is worth adding?

Thanks for sharing it.

This begins to look a lot like the nasty overloaded
PDOStatement::fetchAll. It would also be nice to have fetch_all for a
single column, and then we have it. I'd rather we avoid that if we
want to expand mysqli functionalities. How about adding
mysqli_fetch_all_object? No need for a new constant and we don't back
ourselves into a corner.