php - PHP中的MongoDB更新:在多个ID上更新一个变量(表示为变量)
问题描述
我需要根据 PHP 最后一页中选定的复选框将文本标签更新到 MongoDB 数据库中。
例如,
我选择了 5 个复选框并在文本框中输入了一个文本标签。在下一页中,我需要编写更新语句以将文本标签更新到 5 个选中复选框的数据库中。这意味着 5 个选中的复选框的路径应该具有更新到数据库中的相同文本标签。数据库不包含文本标签属性。notes: selectedIds = selected checkboxes'paths; clusters 没有 textLabel,所以我必须在这里创建?
$manager = new MongoDB\Driver\Manager('mongodb://username:password@localhost:xxxx/db_name?authSource=db_name'); (the $manger works, it includes the information of username, passwork, db_name, and local_host).
$updateResult = array();
foreach($selectedImages as $selectedImages){
$result = $manager->update(
array("filename.anonPath" => $selectedImages),
array("clusters_r37_mcs100.textLabel" => $textLabel),
array_push($updateResult,$result);
);
}
print_r("$updateResult");
我有一个问题:
无论我是否成功更新,终端都不会显示任何内容。但是,当我签入 MongoDB 数据库时,我没有看到任何 textLabel 更新。
谢谢你。
解决方案
推荐阅读
- python - sklearn random forests overwriting each other
- android - 在 ScrollView 上放置 Android 横幅广告
- html - 是否有一种仅 html + css 的方式来跨多个网格同步动态网格列宽?
- react-native - 从服务器加载反应本机包(尝试将其托管在 aws S3 上)用于 Android
- java - 将 sql 参数传递给 jdbcTemplate.query 时,我得到一个带有对象 args 的 SQLException
- python - 打印所有连续子数组
- git - 我可以将更新的分支合并到多个功能分支而不检查每个分支吗?
- javascript - Javascript数组json转换为父子json对象
- java - Talend 中的 tJava 和 tJavaRow 有什么区别?
- pandas - Groupby并连接多列