PHP Classes
Icontem

Subject: Listing Records


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend!

      PHP Classes blog   PHP Object-Relational...   All threads   Listing Records   (Un) Subscribe thread alerts  
Subject:Listing Records
Summary:Listing records using ORM uses a lot of resources
Messages:2
Author:Laurent Dinclaux
Date:2008-10-09 22:23:00
Update:2008-10-10 06:40:24
 

  1. Listing Records   Reply  
Picture of Laurent  Dinclaux
Laurent Dinclaux
2008-10-09 22:39:01
Hi,

I use ORM since a long time now, using my own library.

One big disadvantage of that approach is listing records.

$query = "Select record_id FROM table";
$stmt = $Database->prepare($query);
$stmt->execute($queryValues);

$List = array();
while ( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) {

$List[] = new Object($row['record_id'], $this->Database);

}

This code is damn slow and uses a lot of resources. The array approach of listing records is much faster.

Apart that drawback, Object-Relational Mapping is a must.


  2. Re: Listing Records   Reply  
Picture of Manuel Lemos
Manuel Lemos
2008-10-10 06:40:24
Yes, you are right, when you just want to retrieve a few elements from objects for read-only purposes like listing data or sending newsletters, as it was mentioned in the article, retrieving whole objects is inadequate because it takes more memory and CPU to achieve.

This is something on that Metastorage excels. As described in the article it provides a solution to retrieve data from individual arbitrary object variables for read-only purposes using report classes. The data is returned as arrays like you describe. So it is much more efficient solution.

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2008 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products