You are here: Re: Is this a good idea? « PHP Programming Language « IT news, forums, messages
Re: Is this a good idea?

Posted by Ivαn Sαnchez Ortega on 09/27/50 11:37

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sam.s.kong@gmail.com wrote:

> In ASP, you can use GetRows function which returns 2 by 2 array of
> Recordset.
> Actually, it's a recommended way in ASP when you access DB as it
> disconnects the DB earlier.
[...]
> Is the idea workable?

Yes, it is possible.

No, it is not a good idea.

If you return all the data from a query to a 2-dimensional array, then you
will be putting a excessive overhead into your code: more variables, more
used memory, more wasted CPU cycles. If you have very large tables, you
will run out of memory, everything will start failing, and you won't know
the reason.

Carefully plan your SQL query so you don't get more results than expected.
Return the DB results row by row. Parse them one by one. Use persistent DB
connections. Don't ever work on the entire results of a query: it's a
complete waste of time, and your code will became more complex, and less
mainteable. Know what you're doing, experiment yourself, don't be blinded
by the "recommended ways in ASP".

Also, it's the job of the DB engine to keep track of the query results, not
PHP's. And modern, stable DB engines do support multiple queries at once.
You just have to be a bit careful about concurrent programming.

- --
- ----------------------------------
IvΓ‘n SΓ‘nchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDzYU13jcQ2mg3Pc8RAiWaAJ4oR3uFj19oipF7FsoU3yVWpYdpYACfV8PV
BCZoQyPEOl4+BdOx2tbyxSE=
=wGB6
-----END PGP SIGNATURE-----

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация