0

How can I access the array data (i.e. id, nome, etc) of this:

stdClass Object
(
    [_externalizedData] => Array
        (
            [0] => stdClass Object
                (
                   [id] => 5
                   [tipo_usuario] => 0
                   [username] => [email protected]
                   [nome] => maria
                )
        )
[_explicitType] => flex.messaging.io.ArrayCollection
)
5
  • more code please. what equals that object? Commented Nov 27, 2012 at 0:56
  • I am working to pass to AMFPHP a list of users in a data grid with multirows enabled. It are the parameters passed for Flex application to AMFPHP. Commented Nov 27, 2012 at 0:59
  • See more: stackoverflow.com/questions/13548488/… Commented Nov 27, 2012 at 1:00
  • Ok, I'll ask another way. What did you put to print that object? Commented Nov 27, 2012 at 1:02
  • error_log( print_r( $Object_param, true )); Commented Nov 27, 2012 at 1:08

2 Answers 2

1

Looks like it would be, if $object equals that

$object->_externalizedData[0]->id

as in

echo $object->_externalizedData[0]->id; // 5    
echo $object->_externalizedData[0]->username; // [email protected]

OK more info given, that object = $Object_param and OP wants to fix a loop

foreach ($Object_param->_externalizedData as $Obj)
{ 
    // line breaks just for readability 
    $query="INSERT INTO grupo_usuario 
        (id_grupo,id_usuario) 
        VALUES 
        (1, '" . mysql_real_escape_string($Obj->id) . "')";
    $result = mysql_query($query,$mysql); 
    error_log( print_r( $query, true )); 
}

But you're going to set id_grupo to 1 for each row. Hopefully you know how to sort the SQL out now you see how to get one variable.

Sign up to request clarification or add additional context in comments.

5 Comments

Nice ! But it is not working yet. foreach($Object_param as $Obj){ $query="insert into grupo_usuario (id_grupo,id_usuario) values ('1','".$Obj->_externalizedData[0]->id."')"; $result = mysql_query($query,$mysql); error_log( print_r( $query, true )); }
I have more users passed as parameter and looks like this inside _externalizedData. [1] => stdClass Object ( [id] => 4 [tipo_usuario] => 0 [username] => [email protected] [nome] => john )
:( Result: [Mon Nov 26 23:18:00 2012] [error] [client 189.121.146.49] insert into grupo_usuario (id_grupo,id_usuario) values ('1',''), referer: app:/OnSync.swf
would have been faster if you gave more info in your question but glad it works.
...as in click accept this answer or whatever it says on this!
0

You would access it like this:

$outer_class->_externalizedData[0]->nome

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.