php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38947 Unable to extend mysqli class properly without causing various fatal errors
Submitted: 2006-09-25 10:14 UTC Modified: 2006-09-25 10:26 UTC
From: rk at yes-co dot nl Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.6 OS: Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rk at yes-co dot nl
New email:
PHP Version: OS:

 

 [2006-09-25 10:14 UTC] rk at yes-co dot nl
Description:
------------
Problem with extension of mysqli library.

Reproduce code:
---------------
<?php
//loaded mysql via dl() function  
$server = 'localhost'; $dbname = 'ws_matching';  $username = 'root';  $password = '';  $port = 3306; $socket = '/tmp/mysql.sock';
class example_mysqli extends mysqli{
  function query($query){
    $result = parent::query($query);
    if(mysqli_error($this)){
      throw new exception(mysqli_error($this), mysqli_errno($this));
    }
    return $result;
  }
}
//$my = new mysqli($server,$username,$password,$dbname,$port,$socket); //works properly
$my = new example_mysqli($server,$username,$password, $dbname,$port,$socket);   //gives strange errors
$result = $my->query('SELECT * FROM housesnl_demand');
while($row = $result->fetch_row()){
  print_r($row);
}
$result->close();
$my->close();
?>

Expected result:
----------------
Array ( [0] => 2006-09-25 12:09:58 )

Actual result:
--------------
possible fatal errors:

Fatal error: mysqli_stmt::data_seek() must be derived from example_mysqli::data_seek in Unknown on line 0

Fatal error: mysqli_stmt::bind_param() must be derived from example_mysqli::bind_param in Unknown on line 0


Warning: Wrong parameter count for mysqli_stmt::mysqli_stmt() in /mnt/data/home/rob/public_html/MatchingRevised/strange_error_mysqli.php on line 19


Fatal error: Call to undefined method mysqli_warning::query() in /mnt/data/home/rob/public_html/MatchingRevised/strange_error_mysqli.php on line 11

etc... error changes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-25 10:19 UTC] tony2001@php.net
Parent constructor (parent::__construct()) must be called explicitly when extending MySQLi.
 [2006-09-25 10:26 UTC] rk at yes-co dot nl
I tried that first this is just a simple example of a more complex issue, even when parent constructor is called problems arise
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 01:03:37 2023 UTC