use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\Criteria;
use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
use Org\Mxchange\CoreFramework\Crypto\Cryptable;
use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
*/
private $searchInstance = NULL;
- /**
- * Update criteria instance
- */
- private $updateInstance = NULL;
-
/**
* Database result instance
*/
return $this->searchInstance;
}
- /**
- * Setter for update instance
- *
- * @param $updateInstance An instance of a LocalUpdateCriteria clase
- * @return void
- */
- public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
- $this->updateInstance = $updateInstance;
- }
-
- /**
- * Getter for update instance
- *
- * @return $updateInstance Updateable criteria instance
- */
- public final function getUpdateInstance () {
- return $this->updateInstance;
- }
-
/**
* Setter for debug instance
*
namespace Org\Mxchange\CoreFramework\Result\Database;
// Import framework stuff
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
/**
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseDatabaseResult extends BaseFrameworkSystem {
+ /**
+ * Update criteria instance
+ */
+ private $updateInstance = NULL;
+
/**
* Protected constructor
*
* @return void
*/
- protected function __construct($class = __CLASS__) {
+ protected function __construct (string $className) {
// Call parent constructor
- parent::__construct($class);
+ parent::__construct($className);
+ }
+
+ /**
+ * Setter for update instance
+ *
+ * @param $updateInstance An instance of a LocalUpdateCriteria clase
+ * @return void
+ */
+ public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
+ $this->updateInstance = $updateInstance;
+ }
+
+ /**
+ * Getter for update instance
+ *
+ * @return $updateInstance Updateable criteria instance
+ */
+ public final function getUpdateInstance () {
+ return $this->updateInstance;
}
}
*
* @return void
*/
- protected function __construct($class = __CLASS__) {
+ protected function __construct (string $className) {
// Call parent constructor
- parent::__construct($class);
+ parent::__construct($className);
}
}
*
* @return void
*/
- protected function __construct($class = __CLASS__) {
+ protected function __construct (string $className) {
// Call parent constructor
- parent::__construct($class);
+ parent::__construct($className);
}
}
// Mark it as out-dated
$this->outDated[$criteriaKey] = 1;
- } // END - foreach
+ }
}
/**
$this->currentPos++;
$this->currentRow = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos];
$nextValid = true;
- } // END - if
+ }
// Return the result
return $nextValid;
while (($this->currentPos < $index) && ($this->valid())) {
// Continue on
$this->next();
- } // END - while
+ }
}
/**
if (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos])) {
// Then get it
$current = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos];
- } // END - if
+ }
// Return the result
return $current;
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;
- } // END - if
+ }
// Return the result
return $isValid;
$searchInstance = $criteriaInstance->getSearchInstance();
// And start looking for the result
- $foundEntries = 0;
+ $foundEntries = $this->getAffectedRows();
while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) {
// Get next entry
$this->next();
// Count one up
$foundEntries++;
- } // END - if
- } // END - while
+ }
+ }
// If no entry is found/updated throw an exception
if ($foundEntries == 0) {
// Throw an exception here
throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED);
- } // END - if
+ }
// Set affected rows
$this->setAffectedRows($foundEntries);
* @param $rows Number of affected rows
* @return void
*/
- public final function setAffectedRows ($rows) {
+ public final function setAffectedRows (int $rows) {
$this->affectedRows = $rows;
}
if ($this->find($key)) {
// Then update it
$criteriaInstance->addCriteria($key, $this->getFoundValue());
- } // END - if
- } // END - foreach
+ }
+ }
}
/**
// And stop searching
break;
- } // END - if
- } // END - while
+ }
+ }
// Return the result
return $found;
* @param $code Code number for the exception
* @return void
*/
- public function __construct (FrameworkInterface $class = NULL, $code) {
+ public function __construct (FrameworkInterface $class = NULL, int $code) {
// Is the instance set?
if (is_null($class)) {
// Add a message around the missing class