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 Martin Jay on 05/26/06 19:43

[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.]

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.

>| >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.

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.

>| >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.

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

>| >forth, your "IMO" solution is exactly "IMO". even still, you should
>| >formalize your writing so that the "while" has loop body brakets. any arg
>| >you make against that will be met with some doozy code i'd like you to
>| >interpret that uses your style...like quadruple, single line nested
>| >for/foreach's amongst multinested if's.
>|
>| Perhaps you misunderstood the simple example I posted.
>|
>| But if you post some of your "doozy [sic] code" here I may tidy it up
>| for you if I have time.
>
>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.

Some people would also choose to write:

while(condition}{
}

Would you have a problem with that formatting too?


>finally,

Really?

> i doubt you *could* clean anything up...and i've already handled
>the programmer that wrote the crap.

Is that the programmer who writes the code you post here? Yes, I have
noticed the different formatting style YOU use in YOUR code. Hmmm...

>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?

>| >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!" :(

>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.

> 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.

>| >sixth, i post code that answers questions instead of berating people with
>| >things like this response: "1 - 1 = 0 :^)"...then again, you are (as
>noted
>| >before and maintained now) as useful as a wort...just not as smart!
>|
>| I answered the question without berating anyone. The question was:
>|
>| "...date("m")-1 returns the previous month.
>|
>| But, if the current month is "01", will this return "12" or "00" ?"
>|
>| and my answer was:
>|
>| "'0' would be returned (1 - 1)."

>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 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?

>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.

>| >now, if you'd like to show me some examples of my "bloated" code, go
>| >ahead...i'm festidious when it comes to maintenance and brevity of code,
>so
>| >i'll be waiting. it would also be in your favor to post *your* own code
>that
>| >shows the reduction of bloat and accomplishes the same task as the code
>you
>| >are berating.
>|
>| Haven't we just done that? Didn't you read the message your responded
>| to?

>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.

>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.

>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.

>| >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.

> 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.
--
Martin Jay
Phone/SMS: +44 7740 191877
Fax: +44 870 915 2124

 

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

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