* Criteria to handle
*/
private $criteria = array();
+
/**
* Protected constructor
*
* @return void
*/
public final function addCriteria ($criteriaKey, $criteriaValue) {
- $this->criteria[str_replace('-', '_', $criteriaKey)] = (string)$criteriaValue;
+ // Debug message
+ if (strpos($criteriaKey, 'my-') !== false) $this->debugBackTrace('criteriaKey=' . $criteriaKey);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
+
+ // Add it
+ $this->criteria[$this->convertDashesToUnderscores($criteriaKey)] = (string)$criteriaValue;
}
/**
*/
public function getCriteriaElemnent ($criteriaKey) {
// Convert dashes to underscore
- $criteriaKey = str_replace('-', '_', $criteriaKey);
+ $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria));
// Default is not found
$value = NULL;
if (isset($this->criteria[$criteriaKey])) {
// Then use it
$value = $this->criteria[$criteriaKey];
- }
+ } // END - if
// Return the value
return $value;
// Walk through all entries
foreach ($entryArray as $key => $entry) {
// Convert dashes to underscore
- $key = str_replace('-', '_', $key);
+ $key = $this->convertDashesToUnderscores($key);
// Then walk through all search criteria
foreach ($this->criteria as $criteriaKey => $criteriaValue) {
// Convert dashes to underscore
- $criteriaKey = str_replace('-', '_', $criteriaKey);
+ $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Is the element found and does it match?
if (($key == $criteriaKey) && ($criteriaValue == $entry)) {
// Now walk through all criterias
foreach ($this->criteria as $criteriaKey => $criteriaValue) {
// Convert dashes to underscore
- $criteriaKey = str_replace('-', '_', $criteriaKey);
+ $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Is the value in array or is $onlyKeys empty?
if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) {
// Return the cache key
return $cacheKey;
}
+
+ /**
+ * Count the criteria, e.g. useful to find out if a database query has no limitation (search criteria)
+ *
+ * @return $count Count of all criteria entries
+ */
+ public final function count () {
+ // Return it
+ return count($this->criteria);
+ }
}
// [EOF]