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

The SDK directory does not exist (ubuntu 16.04) (react native) -

python - How to clone or copy a list? -

python - How to use Celery in Tornado with redis as broker and backend? -