OK, the workaround works fine. Here's an example. Right after you call execute() on your prepared statement, hand it to something like this (you don't need $rowName; it's just a string I'm using to label the XML structure I'm building):
Code: Select all
function resultSetToXML(&$stmt, $rowName)
{
$data = mysqli_stmt_result_metadata($stmt);
$fields = array();
$row = array();
$fields[0] = $stmt;
$count = 1;
while($field = mysqli_fetch_field($data))
{
$fields[$count] = &$row[$field->name];
$count++;
}
call_user_func_array(mysqli_stmt_bind_result, $fields);
while ($stmt->fetch())
{
// DO SOMETHING WITH THE ROW.
// I'm adding the column names and values to XML as follows.
AddResultRow($rowName, $row);
}
}
This is the function that the one above is calling to write XML; it shows how you can iterate through the row columns by name like you could before:
Code: Select all
function AddResultRow($rowName, $row)
{
$this->writer->startElement($rowName);
foreach($row as $key => $val)
{
$this->writer->writeElement($key, $val);
}
$this->writer->endElement();
}