In-Portal Issue Tracker

Welcome to the In-Portal Open Source CMS Issue Tracker! This is a central management / tracking tool for all types of tasks / issues / bugs for the In-Portal Project. Before reporting any issues, please make sure to read the Guide into Issue Tracker and How to Properly Test and Report Bugs!

Dependency Graph View Issue ] Relation Graph ] Vertical ]
related to child of duplicate of

Viewing Issue Simple Details
ID Category Type Reproducibility Date Submitted Last Update
0001234 [In-Portal CMS] Database feature request N/A 2012-03-26 12:54 2012-07-25 05:31
Reporter alex View Status public  
Assigned To alex
Priority normal Resolution fixed  
Status closed      
Summary 0001234: Improvements to kDBConnection class (iterator, kDBConnectionDebug class)
Description In-Portal has nice kDBConnection class, that we use in every day operations that require database interaction.

Among all it has following most important methods, that you can use:
* Query - runs sql statement and returns 2-dimensional array with a results
* GetRow - runs sql statement and returns first row only as 1-dimensional array
* GetCol - runs sql statement and returns first field from each resulting row
* GetOne - runs sql statement and returns first column from first row as a string
All of above functions work very well when you don't have thousands rows in database tables you operate.

In case if you have big tables, then idea to create an array of all selected rows inside kDBConnection::Query method (memory allocation #1) and then returning it to calling function (memory allocation #2) isn't a good idea since you get 2x memory allocation as you would normally get when using code from PHP documentation:

$rs = mysql_query($sql);

while ( $row = mysql_fetch_array($rs) ) {


To solve this problem I created kDBConnection::GetIterator method, that allocates memory only where you actually iterate the data you get from Query method:

$rows = $this->Conn->GetIterator($sql);
$row_count = count($rows);

foreach ($rows as $index => $row) {

I also created kDBConnectionDebug class, which is kDBConnection class descendant with Query & GetIterator methods overridden to collect additional statistics while in debug mode. Before kDBConnectionDebug class Query method always called _debugQuery method in first lines of Query method, which was slowing whole DB querying process a bit.
Additional Information

Web Development by Intechnic
In-Portal Open Source CMS
In-Portal Open Source CMS
Copyright © 2000 - 2009 MantisBT Group

Powered by Mantis Bugtracker