如何将MongoDB转换为php - javascript

我在mongodb中有此查询,但我想更改为在php中执行那些查询
我在mongodb中有点新知识,你们能告诉我吗
1。

db.Station.group({
    "key": {
        "OrganizationIdentifier": true
    },
    "initial": {
        "countstar": 0
    },
    "reduce": function(obj, prev) {
        if (true != null) if (true instanceof Array) prev.countstar += true.length;
        else prev.countstar++;
    },
    "cond": {
        "OrganizationIdentifier": {
            "$in": ["R10BUNKER", "USGS-CA"]
        }
    }
});

2。

db.Station.find({
    "$or": [{
        "StateCode": 11
    }, {
        "CountyCode": 55
    }]
}, {
    "MonitoringLocationIdentifier": 1,
    "MonitoringLocationName": 1,
    "MonitoringLocationDescriptionText": 1
});

参考方案

php.net是您入门的绝佳资源

MongoDB:http://php.net/manual/en/class.mongodb.php

MongoCollection ::查找

$projections = array(
    // your projections
    // as in fields you want returned
);

$collection->find(array(
    '$or' => array(
        array('StateCode' => 11),
        array('CountyCode' => 55),
    ),
), $projections);

MongoCollection :: group

$keys = array(
    // your keys
);

$initial = array(
    'countstar' => 0,
);

$reduce = 'function(obj, prev) {
    if (true != null) if (true instanceof Array) prev.countstar += true.length;
    else prev.countstar++;
}';

$options = array(
    'condition' => array(
        // your conditions
    ),
);

$collection->group($keys, $initial, $reduce, $options);

PHP Javascript更改浏览器后退按钮行为Laravel - javascript

我知道有各种各样的线程要求几乎相同的要求,但似乎没有一个真正满足我的需求。在我的网站上,我实现了搜索表单。一个简单的表单,其中包含一个名为searchQuery的输入字段和一个提交按钮。表单通过POST方法发送。我正在使用Laravel btw。。然后将搜索结果从控制器加载到视图中。这些在表中显示。现在来了有趣的部分:找到的元素是可单击的,并且您进入有关该元…

Javascript-从当前网址中删除查询字符串 - javascript

单击提交按钮后,我需要从网址中删除查询字符串值。我可以用jQuery做到这一点吗?当前网址:siteUrl/page.php?key=value 页面提交后:siteUrl/page.php 实际上,我已经从另一个带有查询字符串的页面着陆到当前页面。我需要在页面首次加载时查询字符串值以预填充一些详细信息。但是,一旦我提交了表格,我就需要删除查询字符串值。我已…

如果我得到url(''),我该如何使用另一个URL - javascript

我是新手,正在写这篇文章,但是如果源上没有图像,那么我只有空白。有人可以告诉我,如果我正在获取背景图像,如何获取/images/no-image.jpg:url();这是我的代码:<div class="uk-clearfix uk-position-relative"> <div class="recipeb…

PHP json_encode数组到javascript关联数组 - javascript

我有一些从PHP中读取的mysqli列。它正在完美地获取和回显。$results = mysqli_fetch_assoc(mysqli_query($conn, $querystring)); echo json_encode($results); //$results = {"title":"Sea Shells"…

PHP-显示特殊字符 - javascript

允许用户输入的代码段//fetch user input and pass it in URL alertify.prompt("Please enter note/remarks for this Form (optional):", function (e,value) { if (e) { alertify.success(…