Here are two methods for converting the 'type' and 'flags' attributes to text for debugging purposes. They both use the predefined MYSQLI_ constants to generate the text.
<?php
public static function h_type2txt($type_id)
{
static $types;
if (!isset($types))
{
$types = array();
$constants = get_defined_constants(true);
foreach ($constants['mysqli'] as $c => $n) if (preg_match('/^MYSQLI_TYPE_(.*)/', $c, $m)) $types[$n] = $m[1];
}
return array_key_exists($type_id, $types)? $types[$type_id] : NULL;
}
public static function h_flags2txt($flags_num)
{
static $flags;
if (!isset($flags))
{
$flags = array();
$constants = get_defined_constants(true);
foreach ($constants['mysqli'] as $c => $n) if (preg_match('/MYSQLI_(.*)_FLAG$/', $c, $m)) if (!array_key_exists($n, $flags)) $flags[$n] = $m[1];
}
$result = array();
foreach ($flags as $n => $t) if ($flags_num & $n) $result[] = $t;
return implode(' ', $result);
}
?>