B
B
balex7772019-10-01 07:44:55
Yii
balex777, 2019-10-01 07:44:55

How to specify a condition for the required database table in a findAll query in yii1?

There is a query with connections, I need this condition 'client_id = :client_id', array(':client_id' => 1) Applied only for the Contacts model and its table. In the form that the query is now, it throws an error CDbCommand failed to execute the SQL query: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'client_id' in where clause is ambiguous
Due to the fact that the client_id field exists in several tables, and you need to specify in the condition for which table to apply it. Here is the request. How to do it right?

$model= Contacts::model()->with(
                'staffCompanies',
                'category',
                'staffCompanies.contactsFavourites',
                'staffCompanies.phoneStaffCompanies',
                'staffCompanies.networkStaffCompanies',
                'staffCompanies.emailStaffCompanies',
                'staffCompanies.messengersStaffCompanies'
        )->findAll('client_id = :client_id', array(':client_id' => 1));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arthur, 2019-10-01
@ar2rsoft

findall('table.client_id = :client_id', …)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question