1--TEST-- 2Bug #29311 (Cannot override mysqli constructor) 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 /* class 1 calls parent constructor */ 14 class mysql1 extends mysqli { 15 function __construct() { 16 global $host, $user, $passwd, $db, $port, $socket; 17 parent::__construct($host, $user, $passwd, $db, $port, $socket); 18 } 19 } 20 21 /* class 2 has an own constructor */ 22 class mysql2 extends mysqli { 23 24 function __construct() { 25 global $host, $user, $passwd, $db, $port, $socket; 26 $this->connect($host, $user, $passwd, $db, $port, $socket); 27 } 28 } 29 30 /* class 3 has no constructor */ 31 class mysql3 extends mysqli { 32 33 } 34 35 $foo[0] = new mysql1(); 36 $foo[1] = new mysql2(); 37 $foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket); 38 39 40 for ($i=0; $i < 3; $i++) { 41 if (($result = $foo[$i]->query("SELECT DATABASE()"))) { 42 $row = $result->fetch_row(); 43 if ($row[0] != $db) 44 printf("%d: %s\n", $i, $row[0]); 45 $result->close(); 46 } 47 $foo[$i]->close(); 48 } 49 print "done!"; 50?> 51--EXPECT-- 52done! 53