小编adl*_*son的帖子

Doctrine Mongo更新$ pull查询无效

我正在尝试使用$pull更新查询删除对文档的引用(为了删除所述文档)但是似乎没有发生任何事情.

我可以手动运行以下Mongo查询

db.collection.update({}, {
    $pull: {
        'field': {'$id': ObjectId("xxxxxxxx")}
    }
}, false, true)
Run Code Online (Sandbox Code Playgroud)

哪个工作正常.尝试在Doctrine的ODM中执行相同的操作既不会产生预期结果,也不会产生任何错误消息.这是我们到目前为止所拥有的

$id = new MongoId("xxxxxxxx");

$qb = $repo->createQueryBuilder();
$qb->update();
$qb->field('field')->pull(array('$id' => $id));
$qb->getQuery()->execute();
Run Code Online (Sandbox Code Playgroud)

关于我做错了什么的暗示?

php doctrine mongodb doctrine-odm

2
推荐指数
1
解决办法
1402
查看次数

如何将数组合并到自身?

如果我这样做,print_r($pieces);我得到:

Array
(
    [0] => Albany, NY
)
Array
(
    [0] => Albany, NY
    [1] => Albuquerque, NM
    [2] => Atlanta, GA
    [3] => Augusta, ME
    [4] => Billings, MT
    [5] => Baltimore, MD
)
Array
(
    [0] => Albany, NY
    [1] => Albuquerque, NM
    [2] => Atlanta, GA
    [3] => Augusta, ME
    [4] => Billings, MT
    [5] => Birmingham, AL
    [6] => Boise, ID
    [7] => Boston, MA
    [8] => Buffalo, NY
    [9] => Charleston, SC
    [10] …
Run Code Online (Sandbox Code Playgroud)

php arrays multidimensional-array

2
推荐指数
1
解决办法
2389
查看次数

PHP自动加载功能

我想自动加载函数,而不是类.错误:

PHP致命错误:无法在第7行的/var/www/localhost/proba-function.php中重新声明proba()(之前在/var/www/localhost/proba-function.php:5中声明)

index.php代码:

class ASD {
    function __construct () {
        self::proba();
    }

    public static function __callStatic ( $name, $arguments ) {
        $foo = false;
        $directories = array_diff ( scandir ( __DIR__ ), array ( '..' ) );

        foreach ( $directories as $directory ) {
            $directory = __DIR__ . DIRECTORY_SEPARATOR . $directory;
            if ( is_dir ( $directory ) ) {
                $file = $directory . DIRECTORY_SEPARATOR . strtolower ( $name ) . '-function.php';
                if ( file_exists ( $file ) ) {
                    include …
Run Code Online (Sandbox Code Playgroud)

php function autoload

1
推荐指数
1
解决办法
309
查看次数

HTTP GET:检查var是否为空

我有一个表单,在提交表单时输出以下http字符串:

Field109 = E01&Field112 = E05&Field209 =输入+在+信息+这里%21&Field110 = Field111 = Field113 = Field114 = Field115 = Field116 = Field117 = Field118 = Field119 = Field120 = CreatedBy =公共与dateCreated会= 2013年1月17日+ 08%3A43%3A45&ENTRYID = 14 IP = 98.246.50.81&HandshakeKey =

在我处理提交的PHP脚本中,我检查每个Field以查看它是否已设置.问题是,正如您在上面所看到的,如果表单中的字段在提交时为空,它仍然保留在HTTP字符串中,并isset()认为它已设置并进行处理我告诉它.

如何检查该字段是否真的为空?例如Field110,Field111应该为空,但我的PHP脚本认为它们已设置.

if (isset($_GET["Field110"])) {
    array_push($apnsarray, "E02");
}
if (isset($_GET["Field111"])) {
    array_push($apnsarray, "E03");
}
Run Code Online (Sandbox Code Playgroud)

php variables get isset

0
推荐指数
1
解决办法
229
查看次数