Exemplo n.º 1
0
function mkregall($db, $colname, $tname)
{
    switch ($colname) {
        case 'aptsale':
        case 'flatsale':
        case 'aptrent':
        case 'flatrent':
        case 'officetelrent':
        case 'officetelsale':
        case 'aptlots':
            $grouparr = ['state', 'city', 'county', 'region', 'aptName', 'area'];
            break;
        case 'housesale':
        case 'houserent':
            $grouparr = ['state', 'city', 'county', 'region'];
            break;
        case 'landsale':
            $grouparr = ['state', 'city', 'county', 'region', 'type', 'usedType'];
            break;
        default:
            assert(false);
    }
    mktable($db, $tname);
    mkreg($db, $colname, $tname, $grouparr);
}
Exemplo n.º 2
0
function testreg()
{
    // connect
    $m = new MongoClient();
    // select a database
    $db = $m->selectDB('trend');
    // select a collection (analogous to a relational database's table)
    $colnames = ['housesale', 'aptsale', 'flatsale', 'houserent', 'aptrent', 'flatrent'];
    foreach ($colnames as $colname) {
        $col2name = $colname . "_reg";
        $col2 = new MongoCollection($db, $col2name);
        // Let's remove all first
        $col2->drop([]);
        // add agg information
        mkreg($db, $colname);
    }
}