--TEST--
constructor test
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-
+
/* class 1 calls parent constructor */
class mysql1 extends mysqli {
function __construct() {
/* class 2 has an own constructor */
class mysql2 extends mysqli {
-
+
function __construct() {
global $host, $user, $passwd, $db, $port, $socket;
$this->connect($host, $user, $passwd, $db, $port, $socket);
/* class 3 has no constructor */
class mysql3 extends mysqli {
-
+
}
- $foo[0] = new mysql1();
- $foo[1] = new mysql2();
+ $foo[0] = new mysql1();
+ $foo[1] = new mysql2();
$foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket);
for ($i=0; $i < 3; $i++) {
if (($result = $foo[$i]->query("SELECT DATABASE()"))) {
$row = $result->fetch_row();
- printf("%d: %s\n", $i, $row[0]);
+ if ($row[0] != $db)
+ printf("%d: %s\n", $i, $row[0]);
$result->close();
}
$foo[$i]->close();
}
+ print "done!";
?>
--EXPECTF--
-0: test
-1: test
-2: test
+done!
\ No newline at end of file
--TEST--
-Bug #33263 (mysqli_real_connect in __construct)
+Bug #33263 (mysqli_real_connect in __construct)
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
$stmt = $mysql->prepare("SELECT DATABASE()");
$stmt->execute();
- $stmt->bind_result($db);
+ $stmt->bind_result($database);
$stmt->fetch();
$stmt->close();
- var_dump($db);
+ if ($database != $db)
+ printf("[001] Expecting '%s' got %s/'%s'.\n",
+ gettype($database), $database);
$mysql->close();
+ print "done!";
?>
--EXPECTF--
-%s(4) "test"
+done!
\ No newline at end of file
--TEST--
mysqli->affected_rows
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
<?php
include "connect.inc";
+ $mysqli = new mysqli();
+ if (NULL !== ($tmp = @$mysqli->affected_rows))
+ printf("[000a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
if (0 !== ($tmp = $mysqli->affected_rows))
- printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
+ printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$mysqli->query('DROP TABLE IF EXISTS test'))
printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error);
mysqli_autocommit()
--SKIPIF--
<?php
- require_once('skipif.inc');
+ require_once('connect.inc');
+ require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- exit(1);
+ die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket));
}
- if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
- printf("skip Cannot fetch have_innodb variable\n");
- exit(1);
+ if (!$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
+ die("skip Cannot check for required InnoDB suppot");
}
+ if (!$row = mysqli_fetch_row($result))
+ die("skip Cannot check for required InnoDB suppot");
- $row = mysqli_fetch_row($res);
- mysqli_free_result($res);
+ mysqli_free_result($result);
mysqli_close($link);
-
if ($row[1] == "DISABLED" || $row[1] == "NO") {
- printf ("skip Innodb support is not installed or enabled.");
- exit(1);
+ die(sprintf ("skip innodb support is not installed or enabled."));
}
?>
--FILE--
mysqli->autocommit()
--SKIPIF--
<?php
- require_once('skipif.inc');
+ require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
+ require_once('connect.inc');
if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
'rollback' => true,
'select_db' => true,
'set_charset' => true,
- 'set_local_infile_default' => true,
- 'set_local_infile_handler' => true,
'set_opt' => true,
'stat' => true,
'stmt_init' => true,
if (function_exists('mysqli_ssl_set'))
$expected_methods['ssl_set'] = true;
+ $expected_methods['set_local_infile_default'] = true;
+ $expected_methods['set_local_infile_handler'] = true;
}
/* we should add ruled when to expect them */
Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
mysqli->connect_error = ''/unicode (''/unicode)
mysqli->connect_errno = '0'/integer ('0'/integer)
-done!
\ No newline at end of file
+done!
Number of Parameters: 0
Number of Required Parameters: 0
-Inspecting method 'set_local_infile_default'
-isFinal: no
-isAbstract: no
-isPublic: yes
-isPrivate: no
-isProtected: no
-isStatic: no
-isConstructor: no
-isDestructor: no
-isInternal: yes
-isUserDefined: no
-returnsReference: no
-Modifiers: 256
-Number of Parameters: 0
-Number of Required Parameters: 0
-
-Inspecting method 'set_local_infile_handler'
-isFinal: no
-isAbstract: no
-isPublic: yes
-isPrivate: no
-isProtected: no
-isStatic: no
-isConstructor: no
-isDestructor: no
-isInternal: yes
-isUserDefined: no
-returnsReference: no
-Modifiers: 256
-Number of Parameters: 0
-Number of Required Parameters: 0
-
Inspecting method 'set_opt'
isFinal: no
isAbstract: no
Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
-done!
\ No newline at end of file
+done!
mysqli_free_result($res);
mysqli_close($link);
}
+
+ ini_set('mysqli.default_host', 'p:');
+ if (is_object($link = @mysqli_connect())) {
+ printf("[024] Usage of mysqli.default_host=p: did not fail\n") ;
+ mysqli_close($link);
+ }
}
print "done!";
function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) {
- if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
- printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
- print $sql;
- // don't bail, engine might not support the datatype
- return false;
- }
-
- if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
- printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- if (!is_null($php_value)) {
- if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
- printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
- return false;
- } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
- printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
- return false;
- }
- }
-
- if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
- printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
- return false;
- }
-
- if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) {
- printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
- return false;
- }
- $row = $tmp[0];
-
- $fields = mysqli_fetch_fields($res);
-
- if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
-
- if ($regexp_comparison && !$skip) {
- if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
- printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
- gettype($php_value), $php_value, $regexp_comparison,
- gettype($row[1]), $row[1],
- gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
- return false;
- }
- } else {
- if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
- printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
- gettype($php_value), $php_value,
- gettype($row[1]), $row[1],
- gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
- return false;
- }
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
+ print $sql;
+ // don't bail, engine might not support the datatype
+ return false;
+ }
+
+ if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
+ printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!is_null($php_value)) {
+ if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
+ printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+ return false;
+ } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
+ printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+ return false;
}
- }
+ }
+
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
+ printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) {
+ printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ $row = $tmp[0];
+
+ $fields = mysqli_fetch_fields($res);
+
+ if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
+
+ if ($regexp_comparison) {
+ if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
+ printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
+ gettype($php_value), $php_value, $regexp_comparison,
+ gettype($row[1]), $row[1],
+ gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ } else {
+ if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
+ printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
+ gettype($php_value), $php_value,
+ gettype($row[1]), $row[1],
+ gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ }
+ }
- return true;
+ return true;
}
function func_mysqli_fetch_array_make_string($len) {
Warning: mysqli_fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d
Warning: mysqli_fetch_array(): Couldn't fetch mysqli_result in %s on line %d
-done!
\ No newline at end of file
+done!
func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
// don't care about date() strict TZ warnings...
- $date = date('Y-m-d');
+ $date = @date('Y-m-d');
func_mysqli_fetch_all_oo($link, $engine, "DATE", $date, $date, 410);
func_mysqli_fetch_all_oo($link, $engine, "DATE NOT NULL", $date, $date, 420);
func_mysqli_fetch_all_oo($link, $engine, "DATE", NULL, NULL, 430);
- $datetime = date('Y-m-d H:i:s');
+ $datetime = @date('Y-m-d H:i:s');
func_mysqli_fetch_all_oo($link, $engine, "DATETIME", $datetime, $datetime, 440);
func_mysqli_fetch_all_oo($link, $engine, "DATETIME NOT NULL", $datetime, $datetime, 450);
func_mysqli_fetch_all_oo($link, $engine, "DATETIME", NULL, NULL, 460);
mysqli_free_result($res);
- if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) {
+ if (!$res = mysqli_query($link, "SELECT
+ 1 AS a,
+ 2 AS a,
+ 3 AS c,
+ 4 AS C,
+ NULL AS d,
+ true AS e,
+ 5 AS '-1',
+ 6 AS '-10',
+ 7 AS '-100',
+ 8 AS '-1000',
+ 9 AS '10000',
+ 'a' AS '100000',
+ 'b' AS '1000000',
+ 'c' AS '9',
+ 'd' AS '9',
+ 'e' AS '01',
+ 'f' AS '-02'
+ ")) {
printf("[007] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[008]\n";
[006]
NULL
[008]
-array(5) {
+array(15) {
["a"]=>
string(1) "2"
["c"]=>
NULL
["e"]=>
string(1) "1"
+ [-1]=>
+ string(1) "5"
+ [-10]=>
+ string(1) "6"
+ [-100]=>
+ string(1) "7"
+ [-1000]=>
+ string(1) "8"
+ [10000]=>
+ string(1) "9"
+ [100000]=>
+ string(1) "a"
+ [1000000]=>
+ string(1) "b"
+ [9]=>
+ string(1) "d"
+ ["01"]=>
+ string(1) "e"
+ ["-02"]=>
+ string(1) "f"
}
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
[006]
NULL
[008]
-array(5) {
+array(15) {
[u"a"]=>
unicode(1) "2"
[u"c"]=>
NULL
[u"e"]=>
unicode(1) "1"
+ [-1]=>
+ unicode(1) "5"
+ [-10]=>
+ unicode(1) "6"
+ [-100]=>
+ unicode(1) "7"
+ [-1000]=>
+ unicode(1) "8"
+ [10000]=>
+ unicode(1) "9"
+ [100000]=>
+ unicode(1) "a"
+ [1000000]=>
+ unicode(1) "b"
+ [9]=>
+ unicode(1) "d"
+ [u"01"]=>
+ unicode(1) "e"
+ [u"-02"]=>
+ unicode(1) "f"
}
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
I'm using the procedural interface, this should not throw an exception.
Also, I did not ask to get exceptions using the mysqli_options()
*/
- if ($TEST_EXPERIMENTAL)
+ try {
if (false !== ($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', 'a')))
printf("[011] Should have failed\n");
+ } catch (Exception $e) {
+ printf("%s\n", $e->getMessage());
+ }
mysqli_free_result($res);
Warning: mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
NULL
+Parameter ctor_params must be an array
Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d
\ No newline at end of file