Beispiel #1
0
 /**
  * This function determines whether the last query caused warning messages
  * and stores them in $this->Queries.
  */
 function warnings()
 {
     $Warnings = array();
     if (mysqli_warning_count($this->LinkID)) {
         $e = mysqli_get_warnings($this->LinkID);
         do {
             if ($e->errno == 1592) {
                 // 1592: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.
                 continue;
             }
             $Warnings[] = 'Code ' . $e->errno . ': ' . display_str($e->message);
         } while ($e->next());
     }
     $this->Queries[count($this->Queries) - 1][2] = $Warnings;
 }
Beispiel #2
0
 public function getWarning()
 {
     $war = "";
     if (mysqli_warning_count(self::$connection[self::$active])) {
         $e = mysqli_get_warnings(self::$connection[self::$active]);
         $war .= "<b>Aviso:</b>";
         do {
             $war .= " {$e->errno} - {$e->message}\n<br>";
         } while ($e->next());
     }
     return $war;
 }
<?php

require_once "connect.inc";
if (!($link = my_mysqli_connect($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 (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_warning_unclonable_table_1")) {
    printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_query($link, "CREATE TABLE test_mysqli_warning_unclonable_table_1 (id SMALLINT)")) {
    printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!mysqli_query($link, "INSERT INTO test_mysqli_warning_unclonable_table_1 (id) VALUES (1000000)")) {
    printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
    printf("[005] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), is_object($tmp) ? var_dump($tmp, true) : $tmp);
}
$warning_clone = clone $warning;
print "done!";
$test_table_name = 'test_mysqli_warning_unclonable_table_1';
require_once "clean_table.inc";
$warning = new mysqli_warning();
$warning = new mysqli_warning(null);
$warning = new mysqli_warning(null, null);
$mysqli = new mysqli();
$warning = new mysqli_warning($mysqli);
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($mysqli);
$warning = new mysqli_warning($stmt);
$stmt = $mysqli->stmt_init();
$warning = new mysqli_warning($stmt);
$obj = new stdClass();
$warning = new mysqli_warning($obj);
include "table.inc";
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")');
$warning = mysqli_get_warnings($mysqli);
printf("Parent class:\n");
var_dump(get_parent_class($warning));
printf("\nMethods:\n");
$methods = get_class_methods($warning);
$expected_methods = array('next' => true);
foreach ($methods as $k => $method) {
    if (isset($expected_methods[$method])) {
        unset($methods[$k]);
        unset($expected_methods[$method]);
    }
}
if (!empty($methods)) {
    printf("Dumping list of unexpected methods.\n");
    var_dump($methods);
}