There are three tables
Commodity table goods: The fields are id, goods_id, goods_name, fee, duration, unit, create_time
Software upgrade table upgrade: The fields are id, app_name, china_name , app_version, force_upgrade, download_url, create_time
Software name price list upgrade_access: The fields are id, gid (goods table id), upgrade_id (upgrade table id)
The approximate requirements are : Find the app_name of the software upgrade table corresponding to the product table goods, and then use app_name to find the software name and price detail table upgrade_access. The upgrade_id is the same data corresponding to the product table goods.
I feel like you can’t understand that I use the controller method to search. Out
$data = Db::name('upgrade_access') ->alias('a') ->join('goods b','b.id = a.gid') - >join('upgrade c','c.id = a.upgrade_id') ->where(['app_name'=>$appname]) ->field('fee,goods_name,duration,unit') ->select();
But what I need now is that my boss doesn’t let me use the controller method and asks me to write it in the model layer and then directly use the model layer method
So the model layer should How to write the api is to customize the input value of app_name and use the value of app_name to find the price information of the goods table
You can just throw this into the model and use it.
The writing method of the model is not too different from the writing method of the controller. Build a model yourself. Introduce the model. You can search it on Baidu. This is not difficult