php - Return a large array from a function -


i have class app manages database fetches. instead of working result set (pdostatement) in class , echoing out html there, i'd return result set page using fetchall()

return $stmt->fetchall(pdo::fetch_assoc); 

edit: don't want return $stmt because knowledge not have multiple existing pdostatement objects existing single connection. avoid risk i'd manage these objects within class. please correct me if i'm mistaken.

assuming array won't on 100k rows, maybe 10k-50k, there performance reasons (or @ all) why should not doing this? know it's pretty basic, preferred way of handling this?

will make difference of impact on memory if rather working right in class method? think okay, wanted hear so.

if memory concerns exist calling fetch not friend, regardless of doing... better off calling $stmt->fetch in loop. since php passes arrays reference processing within function vs deferring out should have same memory , performance profile.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -