field checking Follow
Hello,
I have a question regarding "field checking".
Lets have the following code:
1. $sql = "SELECT a FROM my_table WHERE id=12";
2. $result = $myagTools->mysql_query_routine($sql, $mydb_connection);
3. $count_rows = mysql_num_rows($result);
4. $row = mysql_fetch_object($result);
5. $value_a = $row->a;
When I do an inspection of that code with phpStorm, it tells me that there is a field error in line 5, because the inspector does not now, if the field "a" in row 5 is in the table.
As you see in row 2, I use a "special" function to do the sql_query, becuase I use that often in my projects and this routine "mysql_query_routine" is doing all my errorstuff and so on.
So is there a possibility to "tell" phpStorm-inspector, where the fields are defined. And how?
Thanks a lot?
Adrian.
Please sign in to leave a comment.
this is because of slightly buggy stub for mysql_fetch_object. it is corrected for 2.1.2 update.
for now just add
/** @var $row stdClass */
$row=mysql_fetch_object(...)
as a workaround
Thank you, I already did. So will the bugfix get the fieldnames out of the sql-query? That would be great!
Thanks a lot!
Adrian.
Nope, bug fix will only make the @var annotation unneeded.
No inspection warning (on any field name actually) but no completion.
Ok. Thank you a lot!