Code Duplication    Length = 35-35 lines in 2 locations

Alpha/Model/ActiveRecordProviderMySQL.php 1 location

@@ 803-837 (lines=35) @@
800
     *
801
     * @see Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()
802
     */
803
    public function loadAllFieldValuesByAttribute($attribute, $value, $returnAttribute, $order = 'ASC', $ignoreClassType = false)
804
    {
805
        self::$logger->debug('>>loadAllFieldValuesByAttribute(attribute=['.$attribute.'], value=['.$value.'], returnAttribute=['.$returnAttribute.'], order=['.$order.'], ignoreClassType=['.$ignoreClassType.']');
806
807
        if (!$ignoreClassType && $this->BO->isTableOverloaded()) {
808
            $sqlQuery = 'SELECT '.$returnAttribute.' FROM '.$this->BO->getTableName()." WHERE $attribute = '$value' AND classname = '".get_class($this->BO)."' ORDER BY OID ".$order.';';
809
        } else {
810
            $sqlQuery = 'SELECT '.$returnAttribute.' FROM '.$this->BO->getTableName()." WHERE $attribute = '$value' ORDER BY OID ".$order.';';
811
        }
812
813
        $this->BO->setLastQuery($sqlQuery);
814
815
        self::$logger->debug('lastQuery ['.$sqlQuery.']');
816
817
        if (!$result = self::getConnection()->query($sqlQuery)) {
818
            throw new RecordNotFoundException('Failed to load field ['.$returnAttribute.'] values, MySql error is ['.self::getConnection()->error.'], query ['.$this->getLastQuery().']');
819
            self::$logger->debug('<<loadAllFieldValuesByAttribute []');
820
821
            return array();
822
        }
823
824
        // now build an array of attribute values to be returned
825
        $values = array();
826
        $count = 0;
827
        $RecordClass = get_class($this->BO);
828
829
        while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
830
            $values[$count] = $row[$returnAttribute];
831
            ++$count;
832
        }
833
834
        self::$logger->debug('<<loadAllFieldValuesByAttribute ['.count($values).']');
835
836
        return $values;
837
    }
838
839
    /**
840
     * (non-PHPdoc).

Alpha/Model/ActiveRecordProviderSQLite.php 1 location

@@ 808-842 (lines=35) @@
805
     *
806
     * @see Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()
807
     */
808
    public function loadAllFieldValuesByAttribute($attribute, $value, $returnAttribute, $order = 'ASC', $ignoreClassType = false)
809
    {
810
        self::$logger->debug('>>loadAllFieldValuesByAttribute(attribute=['.$attribute.'], value=['.$value.'], returnAttribute=['.$returnAttribute.'], order=['.$order.'], ignoreClassType=['.$ignoreClassType.']');
811
812
        if (!$ignoreClassType && $this->BO->isTableOverloaded()) {
813
            $sqlQuery = 'SELECT '.$returnAttribute.' FROM '.$this->BO->getTableName()." WHERE $attribute = '$value' AND classname = '".get_class($this->BO)."' ORDER BY OID ".$order.';';
814
        } else {
815
            $sqlQuery = 'SELECT '.$returnAttribute.' FROM '.$this->BO->getTableName()." WHERE $attribute = '$value' ORDER BY OID ".$order.';';
816
        }
817
818
        $this->BO->setLastQuery($sqlQuery);
819
820
        self::$logger->debug('lastQuery ['.$sqlQuery.']');
821
822
        if (!$result = self::getConnection()->query($sqlQuery)) {
823
            throw new RecordNotFoundException('Failed to load field ['.$returnAttribute.'] values, SQLite error is ['.self::getLastDatabaseError().'], query ['.$this->BO->getLastQuery().']');
824
            self::$logger->debug('<<loadAllFieldValuesByAttribute []');
825
826
            return array();
827
        }
828
829
        // now build an array of attribute values to be returned
830
        $values = array();
831
        $count = 0;
832
        $RecordClass = get_class($this->BO);
833
834
        while ($row = $result->fetchArray()) {
835
            $values[$count] = $row[$returnAttribute];
836
            ++$count;
837
        }
838
839
        self::$logger->debug('<<loadAllFieldValuesByAttribute ['.count($values).']');
840
841
        return $values;
842
    }
843
844
    /**
845
     * (non-PHPdoc).