more than one atttribute wanted

Hi guys,

following method will give me back exactly one attribut called nachname from table. How do I have to change method in order to get two attributes,for instance surname and firstname





    public static function nachname_for_ekontakt() {

        $nachname = Person::find()

                        ->innerJoin('e_kontakt', 'person.id=e_kontakt.id_person')

                        ->orderBy(['nachname' => SORT_ASC])->asArray()->all();

        return yii\helpers\ArrayHelper::map($nachname, 'id', 'nachname');

    }



Mergings Array won’t help, as few as this





    public static function nachname_for_ekontakt() {


        $nachname = Person::find()

                        ->innerJoin('e_kontakt', 'person.id=e_kontakt.id_person')

                        ->orderBy(['nachname' => SORT_ASC])->asArray()->all();

        return yii\helpers\ArrayHelper::map($nachname, 'vorname', 'nachname');

    }



foreach instead of ArrayHelper::map

If you have full name is database, you have to split it manually first.

Or try


ArrayHelper::getColumn($nachname, function ($element) {

    return $element['surname'] . ' ' . $element['firstname'];

});

(not tested)

Doesn’t work,unfortunately.

I get message:"No matchings found" in DropDownBox, instead there are exactly tree values

The same thing will be with this code

[size="2"]




$nachname = Person::find()->innerJoin('e_kontakt', 'person.id=e_kontakt.id_person')->one();

$fullName = \yii\helpers\ArrayHelper::getValue($nachname, function ($nachname, $defaultValue) {

 return $nachname->vorname . ' ' . $nachname->nachname;          

 });



[/size]