php - Yii2 delete() without primary key -


i want delete data in database delete, table doesn't have primary key

here's code

table::findone(['name' => 'andrew', 'age' => '25'])->delete(); 

then, shows error

app\models\table not have primary key. should either define primary key corresponding table or override primarykey() method. 

help me find way delete without primary key.

thanks

you override primarykey() model method, error should disappear.

inside app\models\table add method (i think primary key should composed 'name' , 'age'):

public static function primarykey() {   return [      'name',      'age',   ]; } 

Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -