I want to create a query that insert a record in my table and update it if its id exist:
what i did is a query to select the record of specific id if the select statement is empty it will insert the data otherwise update, but i think there is a better way to do this in yii2.
there are only more ugly ways as far as I see. When you have to do a great amout of queries and use MySQL the REPLACE command may help you but the best solution for yii is what has been described here.