X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fclasses%2Fmain%2Fresult%2Fclass_DatabaseResult.php;h=4b2c073b5a685398f731ede03de978cba0a50079;hb=e6352b71e923a760d626d6fd32f6223e4c8740fd;hp=0fc85cd11befca1811b5efa19f41ce6869f6e945;hpb=ca915ca6e0366d10ffe557822a891f16c6b2171e;p=core.git diff --git a/inc/classes/main/result/class_DatabaseResult.php b/inc/classes/main/result/class_DatabaseResult.php index 0fc85cd1..4b2c073b 100644 --- a/inc/classes/main/result/class_DatabaseResult.php +++ b/inc/classes/main/result/class_DatabaseResult.php @@ -2,11 +2,11 @@ /** * A database result class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -124,14 +124,14 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up */ public function next () { // Default is not valid - $nextValid = false; + $nextValid = FALSE; // Is the result valid? if ($this->valid()) { // Next entry found, so count one up and cache it $this->currentPos++; $this->currentRow = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; - $nextValid = true; + $nextValid = TRUE; } // END - if // Return the result @@ -181,25 +181,40 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up */ public function valid () { // By default nothing is valid - $isValid = false; + $isValid = FALSE; - // Check if + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] this->currentPos=' . $this->currentPos); + + // Check if all is fine ... if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) { // All fine! - $isValid = true; + $isValid = TRUE; } // END - if // Return the result return $isValid; } + /** + * Returns count of entries + * + * @return $isValid Whether the next/rewind entry is valid + */ + public function count () { + // Return it + return count($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS]); + } + /** * Determines whether the status of the query was fine (BaseDatabaseBackend::RESULT_OKAY) * * @return $ifStatusOkay Whether the status of the query was okay */ public function ifStatusIsOkay () { - return ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY)); + $ifStatusOkay = ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY)); + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] ifStatusOkay=' . intval($ifStatusOkay)); + return $ifStatusOkay; } /** @@ -318,10 +333,11 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up /** * Adds registration elements to a given dataset instance * - * @param $criteriaInstance An instance of a storeable criteria + * @param $criteriaInstance An instance of a StoreableCriteria class + * @param $requestInstance An instance of a Requestable class * @return void */ - public function addElementsToDataSet (StoreableCriteria $criteriaInstance) { + public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { // Walk only through out-dated columns foreach ($this->outDated as $key => $dummy) { // Does this key exist? @@ -341,7 +357,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up */ public function find ($key) { // By default nothing is found - $found = false; + $found = FALSE; // Rewind the pointer $this->rewind(); @@ -357,7 +373,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up // Is the element there? if (isset($currentEntry[$key])) { // Okay, found! - $found = true; + $found = TRUE; // So "cache" it $this->foundValue = $currentEntry[$key]; @@ -381,7 +397,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up * @return void * @todo Find a caching way without modifying the result array */ - public function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack) { + public function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack) { // By default nothing is found $indexValue = 0;