How to iterate over stdClass?

Thanks you all. Well the main goal is to build a xls file from mysql data.
I’ve followed several examples, and I only see examples using mysql_num_rows, and mysql_num_fields, however, I’d like to do that using PDO, and if it makes more sense, to use the FETCH_OBJ for the effect.

Thanks. I’m not actually sure if I understand the concept of an array of objects. When I var_dump $objRecord it seems more that I’m inside an object, that object contains an array, and each key of that array that the object contains, corresponds to a column name that we have fetched.
Am I thinking wrong?

Since I want to grab the property names, to serve as columns on a xls file, maybe then, the foreach may be of no use in this case? :rolleyes:

So, if I’ve properly understood, that will output $property as a string, and then return his value as well… however, something like this:
inside the foreach,
foreach ($objRecord as $property => $property_value)
{
printf(‘$property => %s’ . PHP_EOL, $property->name);
}

Doesn’t seem to work: “Trying to get property of non-object” and it’s right, because, $property is no longer an object right? It was been converted into a string…?

Anyway, I’m getting away from the point.

The main point is, grab rows and columns form our database and put then on a xls, using PDO and fetch_obj for the effect. The question that rises is:
what ways do we have, to look into the object returned, and grab values and properties names and output that?

Regards,
Márcio