In-Portal Issue Tracker - In-Portal CMS
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Type: | Reproducibility: | Date Submitted: | Last Update: |
1234 | [In-Portal CMS] Database | feature request | N/A | 2012-03-26 12:54 | 2012-07-25 05:31 |
|
|||||
Reporter: | alex | Platform: | |||
Assigned To: | alex | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 5.2.0-B2 | ||
Product Build: | Resolution: | fixed | |||
ETA: | none | Fixed in Version: | 5.2.0-B3 | ||
Reference: | https://groups.google.com/d/topic/in-portal-dev/DqcpnhBb8Ro/discussion | ||||
Change Log Message: | Adds ability to iterate database results using Iterator interface descendant class | ||||
Estimate Points: | 1 | ||||
|
|||||
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. |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
db_connection_iterator.patch (22,354) 2012-03-26 12:54 http://tracker.in-portal.org/file_download.php?file_id=1572&type=bug db_loadbalancer_iterator.patch (1,032) 2012-03-26 13:10 http://tracker.in-portal.org/file_download.php?file_id=1573&type=bug db_connection_iterator_getcol_and_fetch_assoc.patch (1,966) 2012-03-27 05:08 http://tracker.in-portal.org/file_download.php?file_id=1575&type=bug |
||||
|
|||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2012-07-25 05:31 | alex | Note Added: 0004948 | |||
2012-07-25 05:31 | alex | Status | resolved => closed | ||
2012-03-27 05:09 | alex | Changeset attached | 5.2.x r15242 | ||
2012-03-27 05:08 | alex | Note Added: 0004527 | |||
2012-03-27 05:08 | alex | File Added: db_connection_iterator_getcol_and_fetch_assoc.patch | |||
2012-03-26 13:11 | alex | Changeset attached | 5.2.x r15240 | ||
2012-03-26 13:11 | alex | Note Added: 0004524 | |||
2012-03-26 13:10 | alex | File Added: db_loadbalancer_iterator.patch | |||
2012-03-26 12:58 | alex | Note Added: 0004523 | |||
2012-03-26 12:58 | alex | Status | reviewed and tested => resolved | ||
2012-03-26 12:58 | alex | Fixed in Version | => 5.2.0-B3 | ||
2012-03-26 12:58 | alex | Resolution | open => fixed | ||
2012-03-26 12:58 | alex | Assigned To | !COMMUNITY => alex | ||
2012-03-26 12:58 | alex | Changeset attached | 5.2.x r15239 | ||
2012-03-26 12:57 | alex | Note Added: 0004522 | |||
2012-03-26 12:57 | alex | Status | needs testing => reviewed and tested | ||
2012-03-26 12:56 | alex | Note Added: 0004521 | |||
2012-03-26 12:56 | alex | Assigned To | => !COMMUNITY | ||
2012-03-26 12:56 | alex | Developer | => alex | ||
2012-03-26 12:56 | alex | Status | active => needs testing | ||
2012-03-26 12:55 | alex | Reference | => https://groups.google.com/d/topic/in-portal-dev/DqcpnhBb8Ro/discussion | ||
2012-03-26 12:54 | alex | New Issue | |||
2012-03-26 12:54 | alex | File Added: db_connection_iterator.patch | |||
2012-03-26 12:54 | alex | Change Log Message | => Adds ability to iterate database results using Iterator interface descendant class | ||
2012-03-26 12:54 | alex | Estimate Points | => 1 |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|