You are here: Re: How do I fetch an array of all field names in a mysql database? « All PHP « IT news, forums, messages
Re: How do I fetch an array of all field names in a mysql database?

Posted by robert on 05/30/06 13:45

| [Follow-ups set to alt.flame. I will continue this with you there if
| you want, but I doubt anyone else here is interested. Or you can
| contact me via email. martin@spam-free.org.uk is a valid email
| address.]

nope..right here will do fine. whomever wants or does not want to read this
thread can simply ignore it.

| In message <%_Edg.11$G82.8@fe06.lga>, robert
| <ab@no.spam-alama-ding-dong> writes
| ><snip>
| >| >first, my example is in keeping with the op's methodology...so that he
| >| >"get's it" through comparison.
| >|
| >| I don't agree with you that it's a good idea to post poor code to help
| >| someone "get's (sic) it."
|
| >again, show me *how* the code was poor.
|
| Let me put it this way: is it code you would be happy to use in anything
| you develop? Would you rate it as good code? Note that I didn't say it
| was bad, just poor, which means it could be improved on.

let me put it this way...YOU said it was poor code. YOU should then describe
specific ways those characteristics that qualify poor merit.

lest i can call you an ass and answer the same when you query as to "why do
you think i'm an ass?" note that i didn't say you are a HUGE ass, just an
ass, which means you have problems finding pants that fit.


| >| >second, how is my code "wrong x 3"?
|
| >| Well, instead of posting responses to all your rants about what you
call
| >| my bad programming and methodology I thought I'd roll them into one.
|
| >which means what? i have 3 bad programming methods in the code i wrote?
you
| >sure a vague fellow...makes you seem like you're stretching a bit without
| >much effect.
|
| I think it's a cultural thing. Some people need to have things
| explained to them in small, easy words. Don't worry about it.

let's stop here for a second. again, YOU'RE saying my code is wrong. i'm
asking you to be specific. while i think being able to read minds would, in
general, be pretty neat, i shudder the prospect of surveying yours.

you can't just drop an insult and expect it to have much impact or meaning
unless you back it with something.

| I didn't say there were three bad programming methods in your code. But
| at least you're not saying there are none, so you presumably see the
| error of your ways.

now there's a logical fallacy!!! "presumably" NOTHING. i make no indications
either way...YOU said i have bad programming habits. that is all that is
evident. man, you're eat-up with stupid.

| >| >third, where are the "magic numbers"? $i is an index counter and is
| >REQUIRED
| >| >by mysql_fetch_field.
| >|
| >| Did I say anything about $i?
|
| >well, again in your vagueness, $i is the ONLY opportunity to be had in
the
| >example i gave for something REMOTELY magical to be infered. since that
WAS
| >you point in your post, why not just tell me where the magic comes into
play
| >in that code.
|
| LOL. Programming isn't magic. You'll be telling me the camera's stolen
| your soul next.

ok...there's a diversion! want to build another strawman?! i no you have NO
idea what "magic numbers" are...which means you're a new kid on the
programming block. to clue you in, those of us in our profession consider it
common nomanclature. it means you should be burdened to find out what it IS,
before you start thowing the term about...especially since there were NO
magic numbers in the code i wrote.

| The magic reference is yours. You never did explain it.

you're talking about another thread...in THIS thread, it's all you baby! "It
relies on 'magic numbers'...". Only a complete idiot would use a term with
which he is wholly unfamiliar!

see the above...common nomanclature in the context of programming.
therefore, it is on you to learn what it is rather than relying on someone
in the programming world to explain it ad-nausium.

| >i understand it just fine...i don't have a problem with it other than
your
| >choice of formatting. it is more clearly understood as:
| >
| >while (condition)
| >{
| >}
|
| Perhaps, but it's only a formatting issue. I don't notice the absence
| of braces in general.

good for you! now were you to have a staff of varying skill levels who have
to maintain thousands of lines of code formatted that way - and under time
constraints - you'd probably take a more practical view of what good
formatting IS.

well...perhaps not since pragmatism seems to be as allusive to you as logic!

| Some people would also choose to write:
|
| while(condition}{
| }
|
| Would you have a problem with that formatting too?

six-one-half-a-dozen-the-other...what IS important is that one is
consistent.


| >finally,
|
| Really?


my, aren't we witty.

| >the very fact that someone would have to be an interpreter while
| >reading your style of body formatting is the very reason it IS bad
| >formatting.
|
| Are you seriously suggest that you could only understand the code I've
| posted after passing it through an interpreter?

i'm saying it is bad form. i'm saying it is hard to interpret when scanning
code or maintaining it. that is compounded when you are learning the
language. i'm saying there are a host of reasons why it is bad form, could
be improved upon, poor code.

as for me in general...i've been programming in c since you were in diapers.
i think i can parse a file visually, pre-build and detect the same errors a
compiler would in addition to understanding what the code will do. what i am
though, is considerate enough to be explicit in everything i write and take
out as much guess-work as possible for the next guy who has to work in the
same codebase.


| >| >fifth, not all db's HAVE a "DESCRIBE" keyword or functionality...i
write
| >| >from experience so that when i say "select * from table where 1 = 2",
i
| >know
| >| >it will return results - mysql or not.
| >|
| >| Not all databases have the SHOW keyword or functionality, so what's
your
| >| point?
|
| Oh no, there is more. You said "finally!" :(

you're wit here only shows your lack of reading comprehension. you posted to
thoughts. i addressed them both (though you snipped for your
convenience)...addressing the second was prefaced with "finally".

what a shame. you just keep going down hill.

| >the point is being flexible. ALL db's will give me a list of fields with
no
| >associated data using "select * from table where 1 = 2".
|
| ALL databases? Wow, that is magic.

more wit? you need a honing stone.

| > your "IMO" post's brevity RELIES on the DESCRIBE/SHOW keywords. you
| >are setting yourself up to redo your work when your boss says "we're
| >going to go to terdata instead of oracle".
|
| Boss? I thought you decided I don't get paid.

more diversions? don't care to defend your point? find nothing wrong with
mine?

to others, that will seem the case. to me, i'm more certain of it. not
having a point or clear thought about anything is the only thing you seem to
do well here.


| >you left out the happy face too...a smug indication that was a
disrespectful
| >jest offered in response to a sincere question.
|
| LOL. You really do read too much into those smiley faces. :)

i think others who read that thread would think you were being a smart ass
for the same reasons as i.

| >| I don't consider this answer to be any less useful than your "you start
| >| by RTFM" reply to message
| >| <1148469014.190473.71330@i40g2000cwc.googlegroups.com>.
|
| >i don't babysit. if it is a question whos answer is so prevelant that it
is
| >all over the web and in manuals with example code galore, we all can tell
| >the op is being LAZY in addition to being a noob. the latter is
completely
| >acceptable while the former simply chaps almost everyone's ass.
|
| How do you tell the difference?

omfg! are you 12? uhhh, having experience with the language, its resources,
professional literature...best of all, i can tell the difference because i
HAVE RTFM and i know how easy/hard it is to find certain information. it's
called experience...which you lack almost as much of as you do common sense.

| >see a difference? had the op said, "i'm having problems with my code
| >uploading files to my server", they'd have gotten a completely different
| >response from me...while i suspect yours would have been another joke -
| >intentional or not.
|
| More of your poor, bloated code? Perhaps the manual is a better option.

time to put up or shut up. show me how my code (any of it in any previous
post, ever) is poor or bloated...then let's see your fix. otherwise, your
gibes land as a feather.


| >no, we haven't...i've posted hoards of code. you're telling me that of
| >all the code i've given, THAT was the one you consider bloated? doesn't
| >make sense
|
| Why? Were your other examples even more bloated? It's almost tempting
| to look through Google Groups so see what you're talking about.

more diversions! i'm telling you to do EXACTLY that. then i'm asking you to
back up your insult with examples of where the code in question is bloated,
how, and how you'd fix it. a request you continually meet by diversion.
apparently i'm confident in what you find as proving you wrong. equally
apparent is your indication, by reluctance to indulge yet continue to
verbalize as insult, that you won't be able to prove you own point by the
end of that exercise.

| >either get your story straight or do as i ask...show me bloated code and
| >your version that fixes it without comprimising the task(s) each attends.
|
| I'm not wasting my time rewriting your code for you. LOL. You've
| already said you have staff who do that for you.

actually, you illiterate baffoon, i correct *their* poor writing habits.

you really must read more often...something more substancial than
dick-and-jane books.

| >bloat == writing a solution in
| >a complex manner when a more simple approach could have been had.
|
| Yours:
|
| $sql = "SELECT * FROM my_table WHERE 1 = 2";
| $records = mysql_query($sql);
| $numFields = mysql_num_fields($records);
| for ($i = 0; $i < $numFields; $i++)
| {
| $field = mysql_fetch_field($records, $i);
| echo $field->name . "<br />\r\n";
| }
|
| Mine:
|
| $result=mysql_query("DESCRIBE $mysql_table");
| while ($row = mysql_fetch_array($result))
| echo $row['Field']."<br>\r\n";
|
| Spot the difference.
|

mine scales and is not db dependant - all things being equal...say an
abstract db class interface rather than directly calling a specific db
interface like mysql_* ; peardb for example.

yours does not scale and is poorly formatted.

having fewer lines of code and thinking it is the better for it is simply a
misgiving...and an oversight of forethought!

| >| >until then, m.j., FOAD
| >|
| >| That seems to have been your attitude to me for a while now. I don't
| >| know why.
|
| >glad you noticed. you should also be painfully aware that such attention
is
| >only directed at you. i'd be about finding out why if our roles were
| >reversed. for starters, you are simply not helpful. more importantly is
| >that, in your non-helpfulness, you are condescending to those with
questions
| >here.
|
| That's your opinion. I don't see anyone else complaining. The personal
| email replies I receive to my newsgroups messages suggest that you are
| in the minority.

whatever...i HAVE looked up all your posts AND their replies. they don't say
much and they certainly RARELY say "thank you".

| > even worse is the proliferation of your responses here. all you've
| >proven with any of this is that you are...lol...not helpful,
condescending,
| >and reply to posts a lot.
|
| You're repeating yourself now.

hey, you got it! i'm saying your efforts in this ng aren't doing anyone any
good...including yourself.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация