<?php
// Own namespace
-namespace CoreFramework\Result\Database;
+namespace Org\Mxchange\CoreFramework\Result\Database;
// Import framework stuff
-use CoreFramework\Criteria\Local\LocalSearchCriteria;
-use CoreFramework\Criteria\Local\LocalUpdateCriteria;
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Database\Backend\BaseDatabaseBackend;
-use CoreFramework\Request\Requestable;
-use CoreFramework\Result\Search\SearchableResult;
-use CoreFramework\Result\Update\UpdateableResult;
-use CoreFramework\Wrapper\Database\DatabaseWrapper;
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
+use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
+use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
+use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
+use Org\Mxchange\CoreFramework\Result\Update\UpdateableResult;
// Import SPL stuff
+use \InvalidArgumentException;
use \SeekableIterator;
/**
/**
* Result array
*/
- private $resultArray = array();
+ private $resultArray = [];
/**
* Array of out-dated entries
*/
- private $outDated = array();
+ private $outDated = [];
/**
* Affected rows
*
* @param $resultArray The array holding the result from query
* @return $resultInstance An instance of this class
+ * @throws InvalidArgumentException If a parameter is invalid
*/
public static final function createCachedDatabaseResult (array $resultArray) {
+ // Misses an element?
+ if (count($resultArray) == 0) {
+ // Cannot be empty
+ throw new InvalidArgumentException('Array "resultArray" cannot be empty.');
+ } elseif (!array_key_exists(BaseDatabaseBackend::RESULT_INDEX_ROWS, $resultArray)) {
+ // Yes, then abort here
+ throw new InvalidArgumentException(sprintf('resultArray(%d)=%s has no element "%s".', count($resultArray), print_r($resultArray, TRUE), BaseDatabaseBackend::RESULT_INDEX_ROWS));
+ }
+
// Get a new instance
$resultInstance = new CachedDatabaseResult();
*/
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
*/
public function valid () {
// By default nothing is valid
- $isValid = FALSE;
+ $isValid = false;
// Debug message
//*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->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
*/
public function rewind () {
$this->currentPos = -1;
- $this->currentRow = array();
+ $this->currentRow = [];
}
/**
* Adds registration elements to a given dataset instance
*
* @param $criteriaInstance An instance of a StoreableCriteria class
- * @param $requestInstance An instance of a Requestable class
* @return void
*/
- public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
+ public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
// Walk only through out-dated columns
foreach ($this->outDated as $key => $dummy) {
// Does this key exist?
*/
public function find ($key) {
// By default nothing is found
- $found = FALSE;
+ $found = false;
// Rewind the pointer
$this->rewind();
// Is the element there?
if (isset($currentEntry[$key])) {
// Okay, found!
- $found = TRUE;
+ $found = true;
// So "cache" it
$this->foundValue = $currentEntry[$key];