Categories > TinyButStrong general >

db object col_names

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2006-06-06
Time: 03:50

db object col_names

I have a mental block on accessing object keys...
I'm trying to create XML from database records - without knowing the col names.
My data object looks like this...
Array
(
[0] => stdClass Object
(
[id] => 7
[category] => Geek
[fname] => Jay
[lname] => Gossamer
[notes] => Wife Mary
[dateentered] => 2006-02-06 07:22:55
)

[1] => stdClass Object
(
[id] => 11
[category] => Politician
[fname] => Elaine
[lname] => Grace
[notes] => Michael and Jonathan
[dateentered] => 2006-02-06 07:22:22
)

[2] => stdClass Object
(
[id] => 25
[category] => Geek
[fname] => Joseph M.
[lname] => Graves Jr
[notes] => Seawind 24
[dateentered] => 2006-02-06 07:22:06
)
)
I want xml that looks like
<record id=25>
<category> Geek </category>
<fname> Joseph M. </fname>
<lname> Graves Jr </lname>
etc
But..how do I get the col names and the vals from the object when I don't know the col names?

What am I missing in this?
By: Skrol29
Date: 2006-06-06
Time: 10:16

Re: db object col_names

Hi,

I suggest to use get_object_vars() in a OnData function.
By: edavison
Date: 2007-10-29
Time: 18:58

Re: db object col_names

I cannot seem to find any documentation on how this would be used.  For me I am trying to query a DB table and display it in a table like this:

+--------+------------+
| col1     | value        |
+--------+------------+
| col2     | value        |
+--------+------------+
| col3     | value        |
+--------+------------+

Could you give an example?
By: TomH
Date: 2007-10-29
Time: 19:50

Re: db object col_names

At the time (June,2006) I was trying to prepare XML data so that I could then use it as the data input to TBS MergeBlock process.

The end result was a prototype for processing generic (data oriented) XML   using TBS as if it were a DB query result.

You can find the example at http://tomhenry.us/tbs3/

Hope that helps,
TomH