Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用$\u GET在带有dql的表中插入带#的值作为参数 我想像这样插入带有“#”的字符串_Php_Doctrine Orm_Dql - Fatal编程技术网

Php 使用$\u GET在带有dql的表中插入带#的值作为参数 我想像这样插入带有“#”的字符串

Php 使用$\u GET在带有dql的表中插入带#的值作为参数 我想像这样插入带有“#”的字符串,php,doctrine-orm,dql,Php,Doctrine Orm,Dql,*我在教义中写过这样的插入代码 $social = new Entities\SocialKeyword; $social->setEventId($_GET["eventId"]); $social->setHashtag($_GET["hashtag"]); $this->em->persist($social); $this->em->flush(); *但是当我像

*我在教义中写过这样的插入代码

         $social = new Entities\SocialKeyword;
         $social->setEventId($_GET["eventId"]);
         $social->setHashtag($_GET["hashtag"]);

        $this->em->persist($social);
        $this->em->flush();
*但是当我像这样在url中提供参数时

         $social = new Entities\SocialKeyword;
         $social->setEventId($_GET["eventId"]);
         $social->setHashtag($_GET["hashtag"]);

        $this->em->persist($social);
        $this->em->flush();
service.biz/index.php/socialkey/abc?eventId=6666&hashtag=#jhfskfgvgusdfdds

在这种情况下,不会向列“hashtag”中添加任何值或字符串,且其为空

但是当我尝试这个的时候 service.biz/index.php/socialkey/abc?eventId=6666&hashtag=jhfskfgvgusdfdfds(平均值不带“#”)

工作正常

那么我如何用#插入它呢


需要帮助。

哈希标记在URL中有意义,并且不是查询字符串的一部分,如果要将其作为get参数传递,则必须对其进行转义

看一看,;hastag的URL编码字符串是
%23
,因此您应该尝试以下方法:

serve.biz/index.php/socialkey/abc?eventId=6666&hashtag=%23jhfskfgvgusdisdfds

话虽如此,也传递hashtag是没有用的,因为这是您想要可视化表示标记的更多部分,而且它甚至不需要在dedb中。最好在视图中呈现标记时添加此项…

我正在创建一个API,该API将从tweeter获取数据。因此将有带有hashtag(“#”)的数据,我必须将它们存储到我的数据库中。因此,我必须包含hashtag。那么,正如我所提到的,您必须正确地转义它。它工作正常,但是,当用户输入这样的hashtag-#abcdefgh,而不是%23abcdefght用户应该使用#,您应该在使用它之前解析它并转义输入。。。软件规则#1:过滤输入,转义输出!