Welcome Guest, Not a member yet? Register   Sign In
XML RPC Server - Indexed array problem
#1

[eluser]CarNinja[/eluser]
Hi,

Most people seem to be having problems with associative arrays. I'm having a problem with indexed arrays. No matter what I do, I can't seem to get this to return a valid response.

Here's the bulk of the code. getbyUserId() returns a result() from an active record db query.

Code:
$qryRecords = $this->weight_model->getByUserId( $objUser->user_id, 99999, 0, false );

$arrResponse = array();

foreach( $qryRecords as $objRecord )
{
    array_push( $arrResponse, array( 'intRecordId' => array( $objRecord->record_id, 'int' )));
}

return $this->xmlrpc->send_response( array( array( 'arrWeightRecords' => array( $arrResponse, 'array' )) , 'struct' ));

Any help is greatly appreciated. I've been tooling on this for about 4 hours now with no luck, and I've scoured the boards and the user guide as well.

Thanks!
#2

[eluser]CarNinja[/eluser]
Anyone?
#3

[eluser]CarNinja[/eluser]
Bueller? Bueller?

I'm still stuck on this... for some reason it just won't take.
#4

[eluser]CarNinja[/eluser]
No one has any input to offer? Come on...
#5

[eluser]CarNinja[/eluser]
Ok, so inside of my foreach loop here, I have 1 line that works, and for some reason I can't use a multidimensional array inside of my indexed array. This is killing me... someone has to know what's going on here...

Please help, this is the last function before my XMLRPC server is complete. I've been stuck on this for 2 days without a single response from the community.


Code:
$qryRecords = $this->weight_model->getByUserId( $objUser->user_id, 99999, 0, false );

$objRecords = array();
$arrWeightRecords = array();

foreach( $qryRecords as $objRecord )
{        
    // This one works...
    array_push( $arrWeightRecords, $objRecord->record_id );

    // None of these work... why?
//    array_push( $arrWeightRecords, array( 'test' => 'something' ));
//    array_push( $arrWeightRecords, array( array( 'test' => array( $objRecord->record_id, 'int' )), 'struct' );
//    array_push( $arrWeightRecords, array( 'intRecordId' => array( $objRecord->record_id, 'int' )));
}

$objRecords = array( 'arrWeightRecords' => array( $arrWeightRecords, 'array' ));

// Give the request back
return $this->xmlrpc->send_response( array( $objRecords, 'struct' ));
#6

[eluser]CarNinja[/eluser]
So I ended up finding a solution. I simply modified the information in the existing structure and passed it to the "convert_to_xmlrpc_values" function that I found on the boards.

Code:
// Pull the weight records
$qryRecords = $this->weight_model->getByUserId( $objUser->user_id, 99999, 0, false );

foreach( $qryRecords as $objRecord )
{
    $objRecord->record_id = array( $objRecord->record_id, 'int' );
    $objRecord->record_datetime = array( date( 'c', strtotime( $objRecord->record_datetime )), 'dateTime.iso8601' );
    $objRecord->record_weight = array( $objRecord->record_weight, 'double' );
}

// Give the request back
return $this->xmlrpc->send_response( $this->convert_to_xmlrpc_values( $qryRecords ));

Thanks for the help, everybody. 8-/
#7

[eluser]skattabrain[/eluser]
HI CarNinja ... I'm trying to pass a query result back as a response and found this thread. What exactly is $this->convert_to_xmlrpc_values?

... later that minute ...

sorry! http://ellislab.com/forums/viewthread/64320/




Theme © iAndrew 2016 - Forum software by © MyBB