views:

18

answers:

1

In my Netbeans PHP projects, I recently started stuffing custom objects into arrays in order to increase performance. I found its much faster to query the database and get a bunch of objects all at once instead of querying over and over again.

I love the new approach, except when I loop through the array and try to access each of the objects, Netbeans doesn't know that the items in the array are actually objects. Try to following example code, for instance:

    foreach ($arrAccounts as $objAccount) {
         echo ( $objAccount->get_name() . " - " . $objAccount->get_type() );
         ...

    }

When I type "$objAccount->", Netbeans doesn't recognize that it is a custom Account class.

+2  A: 

inside the loop add vdoc and enter classname of the $objAccount

Shortcut = [vdoc + tab]

foreach ($arrAccounts as $objAccount) {
    /* @var $objAccount ClassName */
    ...
}
Alex
@Alex - never really bothered to look this up, but sure am glad to know now!
thetaiko
@Alex, that is awesome...plain and simple. Thanks for the response!
eh1160