I read the manual and wrote down the user rights operation plan to use the association model
use a table to associate admin and permissions table before contacting
create table admin_group(
id int auto_increment primary key ,
admin_id int , -sharp
auth_group_id int-sharp
)
1. The administrator table model wants to associate this admin_group table. When inserting an administrator data, it will automatically insert a piece of data into the admin_group
.class Admin extends Model {
public function admin_group(){
$this->hasOne("admin_group","admin_id","id");
}
}
2. This is the AdminGroupmo model
class AdminGroupmo extends Model {
-sharp
}
3. Then call
through other methods in the Admin modelclass Admin extends Model {
public function t2($sqldata){
$this->insert($sqldata);-sharpadmin
$this->admin_group()->save(["auth_group_id"=>"6"]); -sharp
}
}
the result is Call to a member function save () on a non-object
could you tell me which step I made a mistake or? I also want to point it out
.