M
M
Messi2016-10-22 14:52:55
Yii
Messi, 2016-10-22 14:52:55

Why is the request not working through ActiveRecord?

The database has 2 tables:

  1. Request
  2. customer

On the page, you need to display a GridView widget with a filter by the buy_type field.
In the RequestSearch class I do:
$query = Request::find()
        ->select('customer.buy_type, request.id, request.customer_email)
        ->innerJoin('customer', '"request"."email" = "customer"."email"');

This request outputs the data request.id, request.customer_email to the DataProvider, but buy_type does not output, I get an error that the buy_type property is unknown.
And when I make a request like this:
$query = (new \yii\db\Query())
            ->select('customer.buy_type, request.id, request.document_title, 
        request.customer_email, request.doctype_id, request.created')
            ->from('request')
            ->innerJoin('customer', '"request"."customer_email" = "customer"."email"');

Then all the fields are there and everything works. This is not the first time I see this, can you suggest or suggest what the problem is?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-10-22
@FitTech

I see the following errors in the first version:
1 missing quote after request.customer_email
2 instead of '"request"."email" probably should be '"request"."customer_email"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question