You are here: Re: How do mysql_fetch_assoc/mysql_query work? « PHP Programming Language « IT news, forums, messages
Re: How do mysql_fetch_assoc/mysql_query work?

Posted by Jerry Stuckle on 11/29/71 11:56

smythe70@hotmail.com wrote:
> How do mysql_query() and mysql_fetch_assoc() actually work?
>
> When I submit a query to a MySQL database it goes away, works out what
> I requested and throws it back at me. When I submit a query using PHP I
> submit the query using mysql_query and then iterate through the result
> set sing mysql_fetch_assoc() (or mysql_fetch_array() or
> mysql_fetch_row()). What is the purpose of mysql_fetch_xxxx()? Why
> can't mysql_query return a two dimensional array? What trickery is
> going on?
>

Maybe you don't want a 2D array? And what happens if the database
returns a few hundred K rows? Or even a 1k rows with 10K data in each
row. You can rapidly use up a lot of memory that way.

Most of the time I only access one row at a time, and don't need to go
back to a previous row anyway. And when I do I can put everything (or
at least the data I want) in an array.

It also gives me the ability to access the data by the relative position
in the returned row, by the column name, or both. And if I only need
one [i.e. column name], it's more efficient to use only one.

And I'm not sure which language you're talking about when you say " When
I submit a query to a MySQL database it goes away, works out what I
requested and throws it back at me.". Even in C/C++ you need to use
mysql_fetch_row. What language are you using?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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