2

stdclass arrays of php are a good solution to work with data from the database but sometimes they can be a pain in the ass...

Comments
  • 0
    How so? I'm not familiar with how Laravel does things.
    I'm asking because I know a guy who has developed an ORM that uses stdClass objects..
  • 0
    @chasb96 Care to give your opinion on this library I was just referring to?

    https://github.com/Level-2/Maphper

    I was planning on using it in one of my projects but haven't actually gotten to the point of using it yet.
  • 0
    Why not just use a real ORM like Doctrine 2?
  • 0
    @hrombach I considered Doctrine at one point, but it's not the only "real" option. Let's not be biased.
  • 0
    @garrettw that is why I said "like". I just don't like nondescript stdClass objects, they're not much more useful than arrays. What I meant was to use an ORM that uses structured classes and actually maps values to properties.
  • 1
    @hrombach I agree that stdClass objects aren't much different than arrays. Actually an array is more useful as it is iterable whereas stdClass is not (as you can't make it extend ArrayObject or ArrayAccess). Plus there are tons of array helper functions in PHP.
    (Actually you could iterate over stdClass properties but it's not nearly as easy - it involves a lot of reflection.)

    However, when comparing arrays or stdClass objects to concrete class objects, there's this:
    https://github.com/Level-2/Maphper/...
  • 1
    @garrettw concrete class structures yield huge advantages though when you're using a more complex ORM, like, say, Doctrine2. (I would give you more examples but personally I've only ever used Doctrine)
Add Comment