Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Class 'stdclass' not found in mysqli_result.php on line 183 #5042

Closed
rhuanbarreto opened this issue Mar 3, 2017 · 2 comments
Closed

Comments

@rhuanbarreto
Copy link

I got this error from CI.

Environment
IIS 10
PHP 7.0.16

I solved this problem changing the line 183 of mysqli_result.php to

protected function _fetch_object($class_name = '\stdClass')

@marksagal
Copy link

nice

@narfbg
Copy link
Contributor

narfbg commented Mar 6, 2017

Please explain how you managed to trigger this first.

There's at least 2 reasons why it doesn't make sense:

  • A string class name is always interpreted as an absolute (i.e. namespaces included) class path by PHP. In other words, the leading namespace separator is assumed/irrelevant for string class names (as well as in use statements). If this is somehow not the case in some MySQLi function - then it would be a PHP bug.
    This is easily testable:

    $ php -r "namespace Dummy { var_dump(class_exists('stdClass')); }"
    Command line code:1:
    bool(true)
  • CI_DB_mysqli_result is not declared inside a namespace. Thus, even if the former point wasn't true, 'stdClass' would still resolve to \stdClass when relatively searched for, as both classes reside in the root namespace.

Also, linking #5043.

@narfbg narfbg closed this as completed Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants