开发者

What is array portability?

开发者 https://www.devze.com 2022-12-22 16:05 出处:网络
From this page: http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relation开发者_JAVA技巧s:creating-related-records

From this page:

http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relation开发者_JAVA技巧s:creating-related-records

You can see that it says $obj['property']; is the recommended way of referring to an object's property in Doctrine for array portability purposes.

I never heard about this term before and google did not come up with useful result.

What is that?


the examples shows that

$user->Phonenumbers[]->phonenumber = '123 123';
$user->Phonenumbers[]->phonenumber = '456 123';
$user->Phonenumbers[]->phonenumber = '123 777';

will return Phonenumbers[0] = '123 123', Phonenumbers[1] = '456 123' and Phonenumbers[2] = '123 777'

array portability means that you can add more $obj['property']; for next statement. for example if you add more

$user->Phonenumbers[]->phonenumber = 'xxx xxx';

that will be another Phonenumbers[3] = 'xxx xxx' where array index will increase +1.

0

精彩评论

暂无评论...
验证码 换一张
取 消