I have a class function that queries data like so:
// Disclaimer: (None of the following is "real")
class Mockup {
function getData() {
query("SELECT id,name FROM pages")
// Results: $id = 1, $name = "Math Text Book: Grade 7"
}
}
Though I'd like to be able to access both values (That is, $id and $name), I can only return one value individually (Thus creating a disadvantage when compared to simply querying outside of the class).
Would something along the lines of the following be possible in conjunction with the above example code?
$test = new Mockup;
echo $test->getData()->id; // Echos "7"
Similarly, I've seen something along the lines of the following in various software such as MediaWiki:
$test = new Mockup;
echo $test->getData()->getId(); // Echos "7"
Is that an indication that it's also possible to nest functions as well?
query()implicitly creating variables?! What about returning an array of data? It's very unclear to me what issues you have, you'll have to elaborate more. Querying data from a database isn't exactly uncharted territory, so what problem do you have with the standard solutions everyone's using?