英文:
Yii2 MongoDB delete single row from document
问题
尝试删除但无法成功的两种方式如下:
尝试一:
$query = new Query();
$query->delete()->from('table_name')->where(['disease_id' => 'A0PO919Q-12', 'status' => 1]);
尝试二:
$collection = Yii::$app->mongodb->getCollection('table_name');
$collection->delete(['disease_id' => 'A0PO919Q-12']);
有人可以尝试在Yii2框架中从MongoDB中删除数据吗?
英文:
I try this two way to delete but unable to do so:--
Try one:-
$query = new Query();
$query->delete()->from('table_name')->where(['disease_id' => 'A0PO919Q-12', 'status' => 1]);
Try Two:-
$collection = Yii::$app->mongodb->getCollection('table_name');
$collection->delete(['disease_id' => 'A0PO919Q-12']);
Can anyone try to delete data from mongo DB in Yii2 Framewrok
答案1
得分: 0
我找到了解决方案
$collection = Yii::$app->mongodb->getCollection('table_name');
$collection->remove(['disease_id' => 'A0PO919Q-12']);
英文:
I find the solution
$collection = Yii::$app->mongodb->getCollection('table_name');
$collection->remove(['disease_id' => 'A0PO919Q-12']);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论