public function pluck($fieldName)
    {
        $isEmbeddedDocumentField = false !== strpos($fieldName, '.');

        $valueList = array();

        if ($isEmbeddedDocumentField) {
            // get result
            if ($this->isResultAsArray) {
                $cursor = clone $this;
                $documentObjectList = $cursor->asObject()->findAll();
                unset($cursor);
            } else {
                $documentObjectList = $this->findAll();
            }
            // get value of field
            foreach ($documentObjectList as $key => $documentObject) {
                $valueList[$key] = $documentObject->get($fieldName);
            }
        } else {
            // get result
            if ($this->isResultAsArray) {
                $documentArrayList = $this->findAll();
            } else {
                $cursor = clone $this;
                $documentArrayList = $cursor->asArray()->findAll();
                unset($cursor);
            }
            // get values of field
            $valueList = array_column($documentArrayList, $fieldName, '_id');
        }

        return $valueList;
    }
public function pluck($fieldName)
    {
        $isEmbeddedDocumentField = false !== strpos($fieldName, '.');

        $valueList = array();

        if ($isEmbeddedDocumentField) {
            // get result
            if ($this->isResultAsArray) {
                $cursor = clone $this;
                $documentObjectList = $cursor->asObject()->findAll();
                unset($cursor);
            } else {
                $documentObjectList = $this->findAll();
            }
            // get value of field
            foreach ($documentObjectList as $key => $documentObject) {
                $valueList[$key] = $documentObject->get($fieldName);
            }
        } else {
            // get result
            if ($this->isResultAsArray) {
                $documentArrayList = $this->findAll();
            } else {
                $cursor = clone $this;
                $documentArrayList = $cursor->asArray()->findAll();
                unset($cursor);
            }
            // get values of field
            $valueList = array_column($documentArrayList, $fieldName, '_id');
        }

        return $valueList;
    }
public function pluck ( $ fieldName ) { $ isEmbeddedDocumentField = false !== strpos ( $ fieldName , '.' ) ; $ valueList = array ( ) ; if ( $ isEmbeddedDocumentField ) { // get result if ( $ this -> isResultAsArray ) { $ cursor = clone $ this ; $ documentObjectList = $ cursor -> asObject ( ) -> findAll ( ) ; unset ( $ cursor ) ; } else { $ documentObjectList = $ this -> findAll ( ) ; } // get value of field foreach ( $ documentObjectList as $ key => $ documentObject ) { $ valueList [ $ key ] = $ documentObject -> get ( $ fieldName ) ; } } else { // get result if ( $ this -> isResultAsArray ) { $ documentArrayList = $ this -> findAll ( ) ; } else { $ cursor = clone $ this ; $ documentArrayList = $ cursor -> asArray ( ) -> findAll ( ) ; unset ( $ cursor ) ; } // get values of field $ valueList = array_column ( $ documentArrayList , $ fieldName , '_id' ) ; } return $ valueList ; }
Return the values from a single field in the result set of documents

@param string $fieldName
@return array
Return the values from a single field in the result set of documents