Join table and display
<p>I am using the Yii PHP framework, trying to display user_comment and user_reply from two tables who both have a column named comment_id.</p>

<p>This is the comment table</p>

<pre><code>CREATE TABLE `comment` (
  `comment_id` int(11) NOT NULL,
  `byy` varchar(30) NOT NULL,
  `user_comment` varchar(900) NOT NULL,
  `topic_id` varchar(30) NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `up` bigint(11) NOT NULL,
  `down` bigint(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</code></pre>

<p>This is the reply table</p>

<pre><code>CREATE TABLE `reply` (
  `reply_id` int(11) NOT NULL,
  `comment_id` int(19) NOT NULL,
  `byy` varchar(29) NOT NULL,
  `user_reply` varchar(29) NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `up` varchar(29) NOT NULL,
  `down` varchar(29) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</code></pre>

<p>I want to display user_comment and user_reply in a list view format, sorted according to the comment_id. I am having problems with that.</p>

<pre><code>  &lt;?php
    $querys = new Query;
    $querys-&gt;select([
        'comment.user_comment', 
        'reply.user_reply']
        )  
      -&gt;from('comment')
      -&gt;join('LEFT OUTER JOIN', 'reply',
            'reply.comment_id =comment.comment_id') ; 
     $command = $querys-&gt;createCommand();
    $data = $command-&gt;queryAll(); 

    $queryd = new Query;
    $queryd-&gt;select([
        'comment.user_comment', 
        'reply.user_reply']
        )  
      -&gt;from('comment')
      -&gt;join('LEFT OUTER JOIN', 'reply',
            'reply.comment_id =comment.comment_id')    
      -&gt;LIMIT(5); 
     $command = $queryd-&gt;createCommand();
    $data = $command-&gt;queryAll();  


 foreach ($data as $detail) {
        $dataArr[] = array(
            'user_reply' =&gt; $detail['user_reply']
        );
      }
          $dataProvider = new ArrayDataProvider([
                'allModels' =&gt; $dataArr,
                'pagination' =&gt; [
                'pageSize' =&gt; 10,
                ],
                'sort' =&gt; [
                    'attributes' =&gt; ['comment_created_at'],
                ],
            ]);
          echo ListView::widget([
             'dataProvider' =&gt; $dataProvider,
             'itemOptions' =&gt; ['class' =&gt; 'comment-item'],
             'itemView' =&gt; 'adapter',

        ]);
    ?&gt;
</code></pre>

<p>Adapter class</p>

<pre><code>&lt;?php
use yii\helpers\Html;
use yii\helpers\HtmlPurifier;

//var_dump($model);exit;
?&gt;

              &lt;div class="col-lg-12 col-sm-12"&gt;
            &lt;section&gt;

            &lt;?php echo $model['user_reply']; ?&gt;


            &lt;/section&gt;
          &lt;/div&gt;
</code></pre>

<p>I am getting this error:</p>

<blockquote>
  <p>Getting unknown property: Undefined index: user_reply</p>
</blockquote>

<p>What am I doing wrong?</p>