2007-07-23 12:28:56 +00:00
|
|
|
--TEST--
|
|
|
|
mysqli_fetch_fields()
|
|
|
|
--SKIPIF--
|
2007-08-09 10:01:20 +00:00
|
|
|
<?php
|
|
|
|
require_once('skipif.inc');
|
|
|
|
require_once('skipifemb.inc');
|
|
|
|
require_once('skipifconnectfailure.inc');
|
|
|
|
?>
|
2007-07-23 12:28:56 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2009-10-19 20:07:25 +00:00
|
|
|
require_once("connect.inc");
|
2007-07-23 12:28:56 +00:00
|
|
|
|
|
|
|
$tmp = NULL;
|
|
|
|
$link = NULL;
|
|
|
|
|
|
|
|
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
|
|
|
|
if (!is_null($tmp = @mysqli_fetch_fields()))
|
|
|
|
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
|
|
|
|
|
|
|
|
if (!is_null($tmp = @mysqli_fetch_fields($link)))
|
|
|
|
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
|
|
|
|
|
|
|
|
require('table.inc');
|
2012-08-17 13:17:29 +00:00
|
|
|
|
|
|
|
// Make sure that client, connection and result charsets are all the
|
|
|
|
// same. Not sure whether this is strictly necessary.
|
|
|
|
if (!mysqli_set_charset($link, 'utf8'))
|
|
|
|
printf("[%d] %s\n", mysqli_errno($link), mysqli_errno($link));
|
|
|
|
|
|
|
|
$charsetInfo = mysqli_get_charset($link);
|
2010-09-23 15:08:43 +00:00
|
|
|
|
2007-07-23 12:28:56 +00:00
|
|
|
if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
|
|
|
|
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
|
|
|
}
|
|
|
|
|
|
|
|
$fields = mysqli_fetch_fields($res);
|
2010-09-23 15:08:43 +00:00
|
|
|
foreach ($fields as $k => $field) {
|
2007-07-23 12:28:56 +00:00
|
|
|
var_dump($field);
|
2010-09-23 15:08:43 +00:00
|
|
|
switch ($k) {
|
|
|
|
case 1:
|
|
|
|
/* label column, result set charset */
|
2012-08-17 13:17:29 +00:00
|
|
|
if ($field->charsetnr != $charsetInfo->number) {
|
2010-09-23 15:08:43 +00:00
|
|
|
printf("[004] Expecting charset %s/%d got %d\n",
|
2012-08-17 13:17:29 +00:00
|
|
|
$charsetInfo->charset,
|
|
|
|
$charsetInfo->number, $field->charsetnr);
|
2010-09-23 15:08:43 +00:00
|
|
|
}
|
2012-08-17 13:17:29 +00:00
|
|
|
if ($field->length != $charsetInfo->max_length) {
|
2010-09-23 15:08:43 +00:00
|
|
|
printf("[005] Expecting length %d got %d\n",
|
2012-08-17 13:17:29 +00:00
|
|
|
$charsetInfo->max_length,
|
2010-09-23 15:08:43 +00:00
|
|
|
$field->max_length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-07-23 12:28:56 +00:00
|
|
|
|
|
|
|
mysqli_free_result($res);
|
|
|
|
|
|
|
|
if (NULL !== ($tmp = mysqli_fetch_fields($res)))
|
|
|
|
printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
|
|
|
|
|
|
|
|
mysqli_close($link);
|
|
|
|
print "done!";
|
|
|
|
?>
|
2009-07-06 14:36:52 +00:00
|
|
|
--CLEAN--
|
|
|
|
<?php
|
|
|
|
require_once("clean_table.inc");
|
|
|
|
?>
|
2007-07-23 12:28:56 +00:00
|
|
|
--EXPECTF--
|
2011-01-17 10:43:53 +00:00
|
|
|
object(stdClass)#%d (13) {
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"name"]=>
|
|
|
|
%unicode|string%(2) "ID"
|
|
|
|
[%u|b%"orgname"]=>
|
|
|
|
%unicode|string%(2) "id"
|
|
|
|
[%u|b%"table"]=>
|
|
|
|
%unicode|string%(4) "TEST"
|
|
|
|
[%u|b%"orgtable"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"def"]=>
|
|
|
|
%unicode|string%(0) ""
|
2011-01-07 18:25:55 +00:00
|
|
|
[%u|b%"db"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2011-01-17 10:43:53 +00:00
|
|
|
[%u|b%"catalog"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"max_length"]=>
|
|
|
|
int(1)
|
|
|
|
[%u|b%"length"]=>
|
|
|
|
int(11)
|
|
|
|
[%u|b%"charsetnr"]=>
|
|
|
|
int(63)
|
|
|
|
[%u|b%"flags"]=>
|
|
|
|
int(49155)
|
|
|
|
[%u|b%"type"]=>
|
|
|
|
int(3)
|
|
|
|
[%u|b%"decimals"]=>
|
2007-07-23 12:28:56 +00:00
|
|
|
int(0)
|
|
|
|
}
|
2011-01-17 10:43:53 +00:00
|
|
|
object(stdClass)#%d (13) {
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"name"]=>
|
|
|
|
%unicode|string%(5) "label"
|
|
|
|
[%u|b%"orgname"]=>
|
|
|
|
%unicode|string%(5) "label"
|
|
|
|
[%u|b%"table"]=>
|
|
|
|
%unicode|string%(4) "TEST"
|
|
|
|
[%u|b%"orgtable"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"def"]=>
|
|
|
|
%unicode|string%(0) ""
|
2011-01-07 18:25:55 +00:00
|
|
|
[%u|b%"db"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2011-01-17 10:43:53 +00:00
|
|
|
[%u|b%"catalog"]=>
|
2011-01-17 13:06:44 +00:00
|
|
|
%unicode|string%(%d) "%s"
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"max_length"]=>
|
|
|
|
int(1)
|
|
|
|
[%u|b%"length"]=>
|
2010-09-22 18:25:33 +00:00
|
|
|
int(%d)
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"charsetnr"]=>
|
2010-09-22 18:25:33 +00:00
|
|
|
int(%d)
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"flags"]=>
|
2007-07-23 12:28:56 +00:00
|
|
|
int(0)
|
2009-05-28 14:11:41 +00:00
|
|
|
[%u|b%"type"]=>
|
|
|
|
int(254)
|
|
|
|
[%u|b%"decimals"]=>
|
2007-07-23 12:28:56 +00:00
|
|
|
int(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
Warning: mysqli_fetch_fields(): Couldn't fetch mysqli_result in %s on line %d
|
2012-08-17 13:17:29 +00:00
|
|
|
done!
|