The idea is quite simple: the functionality of the
array_walk()
function extends only to arrays.
I thought and decided that it was more interesting for me to apply a callback not only to arrays, but also to iterators, and to strings by character. And yet - to the results returned by other callbacks (this is, for example, the family of
*fetch*()
unsuited used for parsing recordsets when working with a database.
The plus turned out to be obvious: we do not need to transfer the results to the two-dimensional array first, we can feed them to the handler method line by line.
In the project I am working on now, the division into classes View and Model is used, the View forms XML, which is then given to the client, the manipulations with the DBMS are left for the Model.
')
So, what we get as a model method and how it looks (external link for extra beauty, the example uses mysqli):
digital-dog.livejournal.com/296083.html