src/xPDO/xPDO.php
public function addDerivativeCriteria($className, $criteria) {
        if ($criteria instanceof Om\xPDOQuery && ($className = $this->loadClass($className)) && !isset($this->map[$className]['table'])) {
            if (isset($this->map[$className]['fields']['class_key']) && !empty($this->map[$className]['fields']['class_key'])) {
                $criteria->where(array('class_key' => $this->map[$className]['fields']['class_key']));
                if ($this->getDebug() === true) {
                    $this->log(xPDO::LOG_LEVEL_DEBUG, "#1: Automatically adding class_key criteria for derivative query of class {$className}");
                }
            } else {
                foreach ($this->getAncestry($className, false) as $ancestor) {
                    if (isset($this->map[$ancestor]['table']) && isset($this->map[$ancestor]['fields']['class_key'])) {
                        $criteria->where(array('class_key' => $className));
                        if ($this->getDebug() === true) {
                            $this->log(xPDO::LOG_LEVEL_DEBUG, "#2: Automatically adding class_key criteria for derivative query of class {$className} from base table class {$ancestor}");
                        }
                        break;
                    }
                }
            }
        }
        return $criteria;
    }
public function addDerivativeCriteria($className, $criteria) {
        if ($criteria instanceof Om\xPDOQuery && ($className = $this->loadClass($className)) && !isset($this->map[$className]['table'])) {
            if (isset($this->map[$className]['fields']['class_key']) && !empty($this->map[$className]['fields']['class_key'])) {
                $criteria->where(array('class_key' => $this->map[$className]['fields']['class_key']));
                if ($this->getDebug() === true) {
                    $this->log(xPDO::LOG_LEVEL_DEBUG, "#1: Automatically adding class_key criteria for derivative query of class {$className}");
                }
            } else {
                foreach ($this->getAncestry($className, false) as $ancestor) {
                    if (isset($this->map[$ancestor]['table']) && isset($this->map[$ancestor]['fields']['class_key'])) {
                        $criteria->where(array('class_key' => $className));
                        if ($this->getDebug() === true) {
                            $this->log(xPDO::LOG_LEVEL_DEBUG, "#2: Automatically adding class_key criteria for derivative query of class {$className} from base table class {$ancestor}");
                        }
                        break;
                    }
                }
            }
        }
        return $criteria;
    }
public function addDerivativeCriteria ( $ className , $ criteria ) { if ( $ criteria instanceof Om \ xPDOQuery && ( $ className = $ this -> loadClass ( $ className ) ) && ! isset ( $ this -> map [ $ className ] [ 'table' ] ) ) { if ( isset ( $ this -> map [ $ className ] [ 'fields' ] [ 'class_key' ] ) && ! empty ( $ this -> map [ $ className ] [ 'fields' ] [ 'class_key' ] ) ) { $ criteria -> where ( array ( 'class_key' => $ this -> map [ $ className ] [ 'fields' ] [ 'class_key' ] ) ) ; if ( $ this -> getDebug ( ) === true ) { $ this -> log ( xPDO :: LOG_LEVEL_DEBUG , "#1: Automatically adding class_key criteria for derivative query of class {$className}" ) ; } } else { foreach ( $ this -> getAncestry ( $ className , false ) as $ ancestor ) { if ( isset ( $ this -> map [ $ ancestor ] [ 'table' ] ) && isset ( $ this -> map [ $ ancestor ] [ 'fields' ] [ 'class_key' ] ) ) { $ criteria -> where ( array ( 'class_key' => $ className ) ) ; if ( $ this -> getDebug ( ) === true ) { $ this -> log ( xPDO :: LOG_LEVEL_DEBUG , "#2: Automatically adding class_key criteria for derivative query of class {$className} from base table class {$ancestor}" ) ; } break ; } } } } return $ criteria ; }
Add criteria when requesting a derivative class row automatically.

This applies class_key filtering for single-table inheritance queries and may
provide a convenient location for similar features in the future.

@param string $className A valid xPDOObject derivative table class.
@param Om\xPDOQuery $criteria A valid xPDOQuery instance.
@return Om\xPDOQuery The xPDOQuery instance with derivative criteria added.
Add criteria when requesting a derivative class row automatically .