Anonymous | Login | Signup for a new account | 2024-04-26 09:11 CDT |
Main | My View | View Issues | Change Log | Roadmap | Docs | Wiki | Repositories |
Dependency Graph | [ View Issue ] [ Relation Graph ] [ Vertical ] | |||
|
||||
|
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) ) { ... } mysql_free_result($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 |
Main | My View | View Issues | Change Log | Roadmap | Docs | Wiki | Repositories |
Web Development by Intechnic In-Portal Open Source CMS |