开发者

loading data into form when vo object has object inside of it

开发者 https://www.devze.com 2023-03-17 00:38 出处:网络
I\'m building a form to access/create/update based on a vo/dao pattern model that\'s already been made.

I'm building a form to access/create/update based on a vo/dao pattern model that's already been made.

I've been having good luck with <?php echo $product->name ?>开发者_Go百科; since it's just blank if it's not loading an already existant object (using one form for both edit and create).

The problem comes, though, because the $products object contains other objects inside of it, so if I call $product->video->id I get 'Notice: Trying to get property of non-object' if $product->video hasn't been defined yet.

I tried setting $product->video as a new Video in the vo, but it wouldn't let me include the video class.

If having an object inside an object like that is a terrible idea, please let me know also; it seems like a convenient way of dealing with relational tables for now at the very least.


use

<?php
print_r($product)

to expose a structure to you/us

When accessing object which is children of another object you can use

$object1->object2
$object1->object2->object3

but if the other object is array, or like this, you have to use

$object1[ 'object2' ]

or

$object1->object2[ 'object3' ]
0

精彩评论

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

关注公众号