Idea: Multiple fetch styles
shyim opened this issue · 1 comments
shyim commented
I am doing PHP at work, and we have in a popular library Doctrine something like "Fetch styles". That would be I guess a cool thing what could be implemented.
Something like below. Maybe useful also for others 🤔
con.fetchOne('SELECT id from xxx LIMIT 1'); // returns direct the ID
con.fetchAllIndexed('SELECT id, name FROM xxx'); // returns {1: {name: "foo"}}
con.fetchAllKeyValue('SELECT id, name FROM xxx') // returns {1: "foo"}
dgraham commented
This would be useful in a library that uses this driver. The driver itself returns the rows off the wire from mysql for higher-level components to shape into data structures like this.