S
S
Sergey Beloventsev2018-02-07 16:39:45
Yii
Sergey Beloventsev, 2018-02-07 16:39:45

What's wrong with deleteAll?

Tried to organize bulk deletion like this

public function removeList($collection_id, $ids){
        $list=[];
        foreach ($ids as   $ind) {
            $v = static::NormalizeNumber($ind);
            if ($v) {
                $list[] = $v;
            }
        }
        try {
            self::deleteAll(['and',['id'=> $list,'collection_id'=>$collection_id]]);
        }catch (\Exception $e) {
                return $e->getMessage();
            }
        return 'ok';
    }

but does not delete
This is how it shows in the debugger
viber.phone.bulkWrite([{"type":"delete","condition":{"$and":[{"_id":{"$in":["572457469782","572457469783"]}," collection_id":"1"}]},"options":{"limit":0}}])

but no deletion

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-02-13
@kimono

self::deleteAll(['and',['id'=> $list,'collection_id'=>$collection_id]]);

First of all, this andis redundant. You can simply:
Secondly, since it does not delete, perhaps there are no records that match the condition?
Check what it says:
self::find()->where(['id' => $list, 'collection_id' => $collection_id])->count();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question