Re: Std Class Object to Array
- From: sheldonlg <sheldonlg>
- Date: Sun, 16 Aug 2009 20:37:05 -0400
Jerry Stuckle wrote:
sheldonlg wrote:Jerry Stuckle wrote:sheldonlg wrote:Jerry Stuckle wrote:sheldonlg wrote:Jerry Stuckle wrote:sheldonlg wrote:Jerry Stuckle wrote:sheldonlg wrote:Jerry Stuckle wrote:jeff wrote:Jerry Stuckle wrote:jeff wrote:Some background:
I'm moving database data from one server to another, in the process I'm changing (sucky) field names and some other bits.
So, I thought I would json_encode the data set, retrieve it, then json_decode it and iterate through the data one row at a time and insert.
One row looks like this print_r($row):
stdClass Object
(
[REPORT #] => 1994-001
[COMPANY CODE] => 071T
[REVISION NUMBER] => c
[COMPANY INCIDENT #] =>
[REPORT TYPE] => ABNORMAL
[INCDATE] => 1994-03-22 00:00:00
[INCTIME] => NP
[INCTIME2] => ...
I don't know what to do with that. If I try to retrieve a value like this: $row['REPORT #']. I get:
Fatal error: Cannot use object of type stdClass as array.
So, I either need to "fix" that here or when I made the data, which was like this:
$DATA = array();
while($D = $sth->fetch(PDO::FETCH_ASSOC)){
$DATA[] = $D;
}
I thought I was pushing on an array, but apparently that is an object, which mystifies me because at that point I can retrieve fields like an array. For that matter my "field names" were camel case and they are now all uppercase which I don't understand either but can work around.
Pointers or suggestions?
Jeff
I'm curious - if this is any decent database (i.e. other than SQLLite or Access), why not just use the database tools to export from the old system and import to the new? And if you want to change column names, database commands are available there, also.
I'm using MySQL, but the utility is for a MySQL to Access connector. The data is being kept in MySQL and with cleaned up field names, but when reports need to be written, which is often, it goes back to funky format and written to the Access accessible database. This needs to be automated (like clicking a link), rather than manually.
I have this working, I'm just tidying up the code and writing it so I can easily "sync" the remaining tables.
Jeff
No PHP required.
Access can access MySQL, also. No PHP required.
The OP indicates that the people want Access and those tables will have columns with the old names while his MySql has cleaned up names. I don't see how, without code, you can do the column name conversion.
Views, for instance.
OK. That didn't occur to me when I posted.
It's not always necessary to build something new. Many times, just asking for suggestions in the appropriate newsgroup will provide answers.
THAT is what we have been trying to tell you. Also, often, the OP is not sure as to what the appropriate news group is. In this case it would have been better in comp.database.mysql -- but was answered here.
Exactly. And posting a question to comp.databases.mysql before attempting any of this would have saved him the trouble.
True, but as we have been saying the OP often doesn't know which group would eventually have been the right one. Why can't you grasp that?
I have no trouble grasping that - especially in your case, Shelly. But why do you insist on keeping it in this newsgroup when it becomes clear to everyone else it isn't a PHP problem?
And yes, I did let myself get goaded into answering here by you. I
I didn't answer his question. Someone else did and I think you were in on that. The first I commented was to your post where I didn't see that it addressed the OP's concern. In fact, it did as you correctly replied to my post. So, how did I goad you? Anyway, if you read it that way, that was not my intent. I was only addressing a concern that turned out not to be valid. (See, I can admit to an error or oversight).
Because I should not have answered your question here. I should have just told you to follow up in c.d.m. if you wanted more information.
Uh, my question, though incorrect, was that *coding* was required for the OP to do what he wanted. As such, if I were correct, *THIS* would have been the appropriate news group. Since, when I posted the statement, I thought CODING was required, then I was posting to the PROPER news group. The fact that coding is NOT required in no way changes the fact that THIS was the appropriate news group for the comment and NOT c.d.m.
And when I said it could be done completely without coding, it should have been followed up in c.d.m.
Absolutely not since the subject of my post was that it needed coding. I was wrong, but based upon the belief that you had made a mistake in what he needed and that coding WAS required, the perfect place for it was here an c.d.m would have been inappropriate. THAT is what you consistently fail to understand. It is NOT the solution that determines the appropriate place. It is where the question appears to be the most appropriate.
What you fail to understand is that the choice of proper news group is that which is made by what the poster believes to be the problem or solution. This is a classic example. The proper news group for MY comment was HERE because it related to needing coding -- even though the comment was incorrect, while the proper newsgroup for the OP may well have been c.d.m.
Try to understand the distinction.
I understand the distinction. What YOU fail to understand is that you stubbornly continue to follow up in this newsgroup, even when it's not a PHP problem.
Using this post as the example we are talking about, THIS was the proper place to post it.
should have just referred the off topic request to comp.databases.mysql.
....where you, as a participant there, would probably have answered the same thing. So, what is the big, ^%*&%$ deal if you answer in one post here rather than posting to redirect and then answering in a second post with the same information.
Very possibly. But it would have been in the correct newsgroup - and where other people would look if they needed a similar question answer.
People don't look in a news group. They Google and it brings up the appropriate posts which span news groups. Only if they restrict the range to a particular news group will they not find it if they don't choose the right one. So, the point you are trying to make here about helping others has little merit.
Maybe you don't. Smart people do search newsgroups, looking for answers.
What you don't seem to get is there is a reason there are so many newsgroups. But it's evidently too hard for you to follow more than one at a time.
IYNSHO. I follow four technical news groups on a regular basis but generally only post to two. The are c.l.p, a.html, c.l.j and c.d.m. It's not so hard. I do post to this one most of the time because this comprises most of my work.
You would do a lot better if you learned to troubleshoot your problems to the appropriate component before posting to any newsgroup. Yet even when told this isn't a PHP problem, you continue to stubbornly post to this newsgroup.
This was the proper place for that post, not c.d.m for the reasons stated earlier.
I can see where a post is CLEARLY off topic and should be directed to the other group because it is (a) involved and (b) he can get more help there. But where the answer is trivial, the most polite answer (and that is what we are requesting of you) is the simple answer and a note to go to the other group in the future.
We've been through this time and time again, Shelly. When will you learn?
First of all, trivial or not, people will not look in this newsgroup for a similar answer. They will look in an appropriate newsgroup.
The OP will. That is the point. Also, Google will span news groups when searching for anyone else. If you didn't harp so much on it, those threads would end right there, rather than continuing on for twenty or more replies. Comment, yes. Harp, no.
One person will look in the wrong newsgroup. Others will look in appropriate newsgroups.
And yes, Google will span multiple newsgroups - but smart people will search relevant newsgroups to find the answer - eliminating possibly millions of messages with similar keywords.
And note the correct solution is completely independent of any language.
And yes, as long as you stubbornly insist on continuing to ask off-topic questions in this newsgroup, I will continue to harp on your ignorance and incompetence.
I was wondering how long it would take your true nature to rise to the surface. Couldn't keep it under control, could you? Pity.
Second, answering off-topic questions in this or any newsgroup only encourages more off-topic questions.
That is a valid point which I have never contested.
And you are especially good at asking questions which are off-topic to anyone knowledgeable, and don't take them to an appropriate newsgroup when asked.
IYNSHO.
Merely a provable fact. Just look at your history of posts in this newsgroup - including this thread.
IYNSHO.
All we are saying is that people who ask a question don't know the answer beforehand and often don't really know what the best group would be. So, be a little nicer to people.
I am.
ROTFLWTIME
I always try to direct them to a more appropriate newsgroup when I do see one off-topic. Unfortunately, you don't listen and insist on continuing here.
IYNSHO.
Provable, as seen by your posts in this newsgroup, including this thread.
IYNSHO.
Jerry, if you will note I will stubbornly refuse to sinks to the depths of your commenting style. Maybe, just for kicks for a while I might even top-post in response to you - but only you. That is the best way to respond to who acts like a N.N.
--
Shelly
.
- Follow-Ups:
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- References:
- Std Class Object to Array
- From: jeff
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: jeff
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: sheldonlg
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: sheldonlg
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: sheldonlg
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: sheldonlg
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Re: Std Class Object to Array
- From: sheldonlg
- Re: Std Class Object to Array
- From: Jerry Stuckle
- Std Class Object to Array
- Prev by Date: Re: Std Class Object to Array
- Next by Date: Re: Failed opening required 'PEAR.php' (include_path='F:\www\include') in F:\Program Files\PHP\PEAR\Text\CAPTCHA.php on line 22
- Previous by thread: Re: Std Class Object to Array
- Next by thread: Re: Std Class Object to Array
- Index(es):
Relevant Pages
|