0

I am new to Yii / PHP coming from the mainframe/midrange world, so I hope this make sense

I was following Definitive guide to Yii 2.0 and the section on Gii -> CRUD Generator The generated code (Gridview) works great for one table works great and the data-key value in the TR tag is records key value. When I change the code to add a join as shown below, the data-key is not just incremental starting at zero. How can I set the data-key value to the key of the primary table?

The code is below

public function search($params)
    {
 // Generated Code removed
    // $query = HeaderFile::find()

 //New Code added
    $query = new Query;
    $query->from('HeaderFile');
    $query->join('LEFT JOIN', 'DetailFile', 'HeaderFile.KeyField = DetailFile.KeyField');
    $query->where('EmployeeNumber = 123456');


// remaining code
    $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);
Ron
  • 3
  • 2

0 Answers0