如何连接yii2activerecord中的两列?

如何连接yii2activerecord中的两列?,activerecord,yii,yii2,Activerecord,Yii,Yii2,我是yii2(和yii)的新开发人员。我有一个查询,返回客户的姓名和姓氏以及其他列。我正在使用activeDataProvider显示表中的记录,但我需要在一个表列中显示名称和lastname 我想知道的是: 1. how do I concatenate the columns in yii2 activerecord? 2. How do I display the columns in one table columns made gridView? 以下是我尝试过的没有一个有效的方法:

我是yii2(和yii)的新开发人员。我有一个查询,返回客户的姓名和姓氏以及其他列。我正在使用activeDataProvider显示表中的记录,但我需要在一个表列中显示名称和lastname

我想知道的是:

1. how do I concatenate the columns in yii2 activerecord?
2. How do I display the columns in one table columns made gridView?
以下是我尝试过的没有一个有效的方法:

1. $query->select(['customer.*', 'fullname'=>concat('customer.name'," ",'customer.lastname')]);
2. 'dataProvider' => $model['dataProvider'],
                'columns' => [
                  'id',
                  'name'.' '.'lastname',
                  'customer_orders',
                  'created_at:datetime'

使用GridView如下所示

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        [
           'attribute' => 'name',
           'value' => function ($model) {
               return $model->name . ' ' . $model->lastname;
           }
        ]
        'customer_orders',
        'created_at:datetime'
    ]
]) ?>


请参考下面的使用网格视图

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        [
           'attribute' => 'name',
           'value' => function ($model) {
               return $model->name . ' ' . $model->lastname;
           }
        ]
        'customer_orders',
        'created_at:datetime'
    ]
]) ?>

提及