简体   繁体   English

用 PHP 对 MongoDb 进行消毒

[英]Sanitize MongoDb with PHP

I have this code:我有这个代码:

$pid = $_GET["pid"];

$manager = new MongoDb\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDb\Driver\Query(["pid" => $pid]);

$rows = $manager->executeQuery("shop.products", $query);

Is there a way to sanitize the $pid with php?有没有办法用 php 清理$pid Thank you.谢谢你。

You can cast $pid to a string in the query to guard against it being a mapping.您可以将$pid转换为查询中的字符串,以防止它成为映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM