Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-229

Return query result as object instead of array for laravel/database compatibility

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • laravel-5.0.0
    • Affects Version/s: None
    • Component/s: Laravel
    • None
    • PHP Drivers
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Laravel’s Query Builder always returns objects (source).

      - ['typeMap' => ['root' => 'array', 'document' => 'array']]
      + ['typeMap' => ['root' => 'object', 'document' => 'array']]
      

      This is a major breaking change that requires changing all array access into property access. Returning a MongoDB\Model\BSONDocument and MongoDB\Model\BSONArray is not possible as the data is casted with native PHP cast feature in Laravel code: (object) $result and (array) $result.

            Assignee:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: