Using Mapper to parse records

    The idea is quite simple: the features of the function array_walk()apply only to arrays. I thought and decided that I’m more interested in applying callbacks not only to arrays, but also to iterators and strings character by character. And yet - to the results returned by other callbacks (for example, this is a family of different suits *fetch*()used for parsing records when working with a database.

    Plus it turned out to be obvious: we don’t need to first transfer the results to a two-dimensional array, we can feed them to the handler method line by line.

    The project I'm working on now uses the separation of View and Model classes, View generates XML, which is then given to the client, DBMS manipulations are left to the Model.

    So, what do we get as a model method and how does it look (external link for additional beauty, the example uses mysqli):

    Also popular now: