Exemplo n.º 1
0
$tmp = NULL;
$link = NULL;
$test_table_name = 'test_mysqli_stmt_sqlstate_table_1';
require 'table.inc';
if (!($stmt = mysqli_stmt_init($link))) {
    printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) {
    printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test_mysqli_stmt_sqlstate_table_1")) {
    printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if ('00000' !== ($tmp = mysqli_stmt_sqlstate($stmt))) {
    printf("[007] Expecting string/00000, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if (mysqli_stmt_prepare($stmt, "SELECT believe_me FROM i_dont_belive_that_this_table_exists")) {
    printf("[008] Should fail! [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
if ('' === ($tmp = mysqli_stmt_sqlstate($stmt))) {
    printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
}
mysqli_stmt_close($stmt);
if (NULL !== ($tmp = mysqli_stmt_sqlstate($stmt))) {
    printf("[010] Expecting NULL, got %s/%s\n");
}
mysqli_close($link);
print "done!";
error_reporting(0);
$test_table_name = 'test_mysqli_stmt_sqlstate_table_1';
require_once "clean_table.inc";
Exemplo n.º 2
0
 protected function _set_stmt_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = mysqli_stmt_sqlstate($this->_result);
     }
     $this->_set_error(mysqli_stmt_errno($this->_result), mysqli_stmt_error($this->_result), $state, $mode, $func);
 }
printf("stmt->errno = '%s'\n", $stmt->errno);
assert(mysqli_stmt_error($stmt) === $stmt->error);
printf("stmt->error = '%s'\n", $stmt->error);
assert(mysqli_stmt_error_list($stmt) === $stmt->error_list);
var_dump("stmt->error = ", $stmt->error_list);
assert(mysqli_stmt_field_count($stmt) === $stmt->field_count);
printf("stmt->field_count = '%s'\n", $stmt->field_count);
assert($stmt->id > 0);
printf("stmt->id = '%s'\n", $stmt->id);
assert(mysqli_stmt_insert_id($stmt) === $stmt->insert_id);
printf("stmt->insert_id = '%s'\n", $stmt->insert_id);
assert(mysqli_stmt_num_rows($stmt) === $stmt->num_rows);
printf("stmt->num_rows = '%s'\n", $stmt->num_rows);
assert(mysqli_stmt_param_count($stmt) === $stmt->param_count);
printf("stmt->param_count = '%s'\n", $stmt->param_count);
assert(mysqli_stmt_sqlstate($stmt) === $stmt->sqlstate);
printf("stmt->sqlstate = '%s'\n", $stmt->sqlstate);
printf("\nAccess to undefined properties:\n");
printf("stmt->unknown = '%s'\n", @$stmt->unknown);
@($stmt->unknown = 13);
printf("stmt->unknown = '%s'\n", @$stmt->unknown);
printf("\nPrepare using the constructor:\n");
$stmt = new mysqli_stmt($link, 'SELECT id FROM test_mysqli_class_mysqli_stmt_interface_table_1 ORDER BY id');
if (!$stmt->execute()) {
    printf("[002] [%d] %s\n", $stmt->errno, $stmt->error);
}
$stmt->close();
$obj = new stdClass();
if (!is_object($stmt = new mysqli_stmt($link, $obj))) {
    printf("[003] Expecting NULL got %s/%s\n", gettype($stmt), $stmt);
}
 protected function _set_stmt_error($state = null, $mode = EhrlichAndreas_Pdo_Abstract::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = mysqli_stmt_sqlstate($this->_result);
     }
     $this->_set_error(mysqli_stmt_errno($this->_result), mysqli_stmt_error($this->_result), $state, $mode, $func);
 }