[eluser]Nick Husher[/eluser]
Code:
$query = $this->db->query("SELECT * FROM AR_Customer");
$myarray = array();
foreach($query->result() as $row)
{
$myarray[$row->CustomerNo] = array(
'CustomerNo' => $row->CustomerNo,
'CustomerName' => $row->CustomerName
);
}
$response = array($myarray, 'array');
// Give the request back
return $this->xmlrpc->send_response($response);
The issue here is that you're assigning a type of Array, but the data that you are sending is not contiguously indexed. For example, if you have customer numbers of [0,3,9,41,42,43,121], your array will look like [0=>"Customer 0", 1=>undefined, 2=>undefined ... 9=>"Customer 9" ...]. When the loop that's cycling over your array gets to index 1, it dies, becuase index 1 is undefined.
You can find the relevant code in your CI project under /system/libraries/Xmlrpc.php on line 1341. Here's what it looks like:
Code:
// array
$rs .= "<array>\n<data>\n";
for($i=0; $i < sizeof($val); $i++)
{
$rs .= $this->serializeval($val[$i]);
}
$rs.="</data>\n</array>\n";
break;
You can see that it's doing a linear iteration of your array, which will fail if your indexes aren't contiguous.