This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194053 - Code completion fails with mysqli query result variable
Summary: Code completion fails with mysqli query result variable
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: All All
: P4 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-05 13:38 UTC by Jeffrey Rubinoff
Modified: 2016-09-29 12:55 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Screenshot showing cc failure for result variable (2.58 KB, image/png)
2011-01-05 13:39 UTC, Jeffrey Rubinoff
Details
Screenshot showing cc failure to show functions for result variable (2.91 KB, image/png)
2011-01-05 13:39 UTC, Jeffrey Rubinoff
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Rubinoff 2011-01-05 13:38:14 UTC
I was writing a function in a class. NetBeans IDE code completion was not recognizing a query result variable. In procedural style mysqli NetBeans had no problem with this.
The class is a singleton that extends mysqli. The function is

public function get_wisher_id_by_name($name) {
        $name = $this->real_escape_string($name);
        $result = $this->query("SELECT id FROM wishers WHERE name = '"
                        . $name . "'");

        if ($result->num_rows > 0)
            return $result->data_seek(0);
        else
            return null;
        $result->free;
}

The problem is with the $result variable. I started to type $res but nothing showed in cc, not even when I hit ctrl-shift. (See attached screenshot, variable-cc-failure)

When I typed in $result-> manually, again no code completion for the mysqli_result::x functions. (See attached screenshot, function-cc-failure)

The manually-entered code runs without problem.
Comment 1 Jeffrey Rubinoff 2011-01-05 13:39:04 UTC
Created attachment 104729 [details]
Screenshot showing cc failure for result variable
Comment 2 Jeffrey Rubinoff 2011-01-05 13:39:39 UTC
Created attachment 104730 [details]
Screenshot showing cc failure to show functions for result variable
Comment 3 Ondrej Brejla 2011-08-31 12:11:35 UTC
mysqli::query() returns mixed type, it returns MySQLi_Result only in a specific case (only for SELECT, SHOW, DESCRIBE or EXPLAIN query), so it's expected behaviour and not a defect...imho it's P4/Enhancement.
Comment 4 minimihi 2015-10-14 05:54:31 UTC
It's for version 8.0.2, but should be valid for 7.0 as well.

Changing "query" method return type from "mixed" to "mysqli_result" (or "bool|mysqli_result") in /phpstubs/phpruntime/mysqli.php helps intelisense to generate autocomplete.
Comment 5 MerceanCoconut 2016-09-29 12:55:50 UTC
Above workaround worked for me for version 8.2. Line 588 was the one that needed to be edited.