|  | Posted by Peter Fox on 07/03/39 11:37 
Following on from Iván Sánchez Ortega's message. . .>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.
 >
 Err... Sometimes it is a cracking good idea.
 Small result sets only.
 
 Repetitive reference
 
 Read-only...
 .... or lots of writes (eg increments) during a process (followed by a DB
 write of course)
 
 Standard data structure to pass to other functions.
 
 An encapsulated result can sometimes be a lot easier to work with
 outside of stepping through a database.
 
 Also where you are extracting variable information from the DB and want
 to trap errors and anomalies in the data/query at the database level and
 so be sure of passing a clean dataset to the caller.
 
 But as you say, if it is logical to plod through the result set record
 by record then that's the low overhead method of choice - Probably 95%
 of the time.
 
 
 
 >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.
 >
 
 --
 PETER FOX Not the same since the submarine business went under
 peterfox@eminent.demon.co.uk.not.this.bit.no.html
 2 Tees Close, Witham, Essex.
 Gravity beer in Essex  <http://www.eminent.demon.co.uk>
  Navigation: [Reply to this message] |