Using dataSeek should be more efficient

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2015-06-10 22:54:39 +05:30
parent 9081189a9a
commit bd911c8658
3 changed files with 48 additions and 30 deletions

View File

@ -388,12 +388,15 @@ class Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr[0];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr[0];
$count++;
} else {
break;
}
}
$pos--;
}
}
return $retval;

View File

@ -437,12 +437,15 @@ class Node_Database extends Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr[0];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr[0];
$count++;
} else {
break;
}
}
$pos--;
}
}
}
@ -519,12 +522,15 @@ class Node_Database extends Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
} else {
break;
}
}
$pos--;
}
}
}
@ -599,12 +605,15 @@ class Node_Database extends Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr['Name'];
$count++;
} else {
break;
}
}
$pos--;
}
}
}

View File

@ -180,12 +180,15 @@ class Node_Table extends Node_DatabaseChild
}
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Field'];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr['Field'];
$count++;
} else {
break;
}
}
$pos--;
}
break;
case 'indexes':
@ -234,12 +237,15 @@ class Node_Table extends Node_DatabaseChild
}
$count = 0;
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr['Trigger'];
$count++;
if ($GLOBALS['dbi']->dataSeek($handle, $pos)) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($count < $maxItems) {
$retval[] = $arr['Trigger'];
$count++;
} else {
break;
}
}
$pos--;
}
break;
default: