Undefined field...
Picure attached. Why do I get these warnings when there are vars, return from a sql statement? Happens on every statement. I know I can turn the feature off, but why doesn't the IDE know these are elements of an array?
Attachment(s):
Screen shot 2011-06-06 at 11.18.52 AM.png
Screen shot 2011-06-06 at 1.33.51 AM.png
Please sign in to leave a comment.
Hi Stephen,
How $ticket_row is defined, what type (in other words, what do you see when invoking "View | Quick Documentation Lookup" on it)?
Try adding this PHPDoc comment after $ticket_row definition/assignment (or whenever you are using it -- separate template file, I guess):
As of v2.1 (I believe) PhpStorm will not mark such fields as undefined for stdClass ( http://youtrack.jetbrains.net/issue/WI-2839?projectKey=WI )
Maybe because PhpStorm does not actually execute your SQL commands and therefore does not know which fields are returned etc.
Ok got it. Thanks.
PS: $ticket_row
foreach ($db->get_results($sql) as $ticket_row) { ....
get_resutls() is a method in my databsse class (a heavly modified version of the ezsql database class). The method runs a query and returns the resutls in an array. The class itself is a wrapper around mysqli (and the PDO - sometimes).