PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 15, 2022

[FIXED] Understanding _ids array in CakePHP model data

 February 15, 2022     cakephp, cakephp-3.0, orm, php     No comments   

Issue

Using CakePHP v3.1 w/ Postgres DB. When I retrieve records with associations I often see an extra array of _ids. Something like this:

    ...
    (int) 26 => [
        'agency_id' => (int) 23,
        'routes' => [
            '_ids' => (int) 2
        ]
    ]

Or sometimes:

     '_ids' => Array (
        0 => 1
        1 => 5
        2 => 3
        3 => 4
     )
]

I would like to understand:

  1. How and why do these magic _ids appear?
  2. Is there a way to control or prevent that behavior?

Solution

How and why do these magic _ids appear?

The _ids property generally comes in from request data. It could be left behind on an entity if the association isn't completely marshalled though.

If you an provide a way to reproduce _ids coming out of the ORM, please open an issue on github as that shouldn't be happening.



Answered By - Mark Story
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing