Save bytes
This commit is contained in:
parent
2a08a11e89
commit
6e4dc3911f
|
@ -274,7 +274,7 @@ if (isset($_GET["mongo"])) {
|
||||||
(is_a($val, 'MongoDB\BSON\UTCDatetime') ? $val->toDateTime()->format('Y-m-d H:i:s') :
|
(is_a($val, 'MongoDB\BSON\UTCDatetime') ? $val->toDateTime()->format('Y-m-d H:i:s') :
|
||||||
(is_a($val, 'MongoDB\BSON\Binary') ? $val->bin : //! allow downloading
|
(is_a($val, 'MongoDB\BSON\Binary') ? $val->bin : //! allow downloading
|
||||||
(is_a($val, 'MongoDB\BSON\Regex') ? strval($val) :
|
(is_a($val, 'MongoDB\BSON\Regex') ? strval($val) :
|
||||||
(is_object($val) ? json_encode($val, JSON_UNESCAPED_UNICODE) :
|
(is_object($val) ? json_encode($val, 256) : // 256 = JSON_UNESCAPED_UNICODE
|
||||||
$val // MongoMinKey, MongoMaxKey
|
$val // MongoMinKey, MongoMaxKey
|
||||||
)))));
|
)))));
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ if (isset($_GET["mongo"])) {
|
||||||
$limit = min(200, max(1, (int) $limit));
|
$limit = min(200, max(1, (int) $limit));
|
||||||
$skip = $page * $limit;
|
$skip = $page * $limit;
|
||||||
$query = new MongoDB\Driver\Query($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort));
|
$query = new MongoDB\Driver\Query($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort));
|
||||||
$results = $connection->_link->executeQuery("{$connection->_db_name}.$table", $query);
|
$results = $connection->_link->executeQuery("$connection->_db_name.$table", $query);
|
||||||
return new Min_Result($results);
|
return new Min_Result($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +521,14 @@ if (isset($_GET["mongo"])) {
|
||||||
if (!in_array($op, $operators)) {
|
if (!in_array($op, $operators)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (preg_match('~^\(f\)(.+)~', $op, $match)) {
|
||||||
|
$val = (float) $val;
|
||||||
|
$op = $match[1];
|
||||||
|
} elseif (preg_match('~^\(date\)(.+)~', $op, $match)) {
|
||||||
|
$dateTime = new \DateTime($val);
|
||||||
|
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
||||||
|
$op = $match[1];
|
||||||
|
}
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
case '=':
|
case '=':
|
||||||
$op = '$eq';
|
$op = '$eq';
|
||||||
|
@ -543,60 +551,6 @@ if (isset($_GET["mongo"])) {
|
||||||
case 'regex':
|
case 'regex':
|
||||||
$op = '$regex';
|
$op = '$regex';
|
||||||
break;
|
break;
|
||||||
case '(f)=':
|
|
||||||
$op = '$eq';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(f)!=':
|
|
||||||
$op = '$ne';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(f)>':
|
|
||||||
$op = '$gt';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(f)<':
|
|
||||||
$op = '$lt';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(f)>=':
|
|
||||||
$op = '$gte';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(f)<=':
|
|
||||||
$op = '$lte';
|
|
||||||
$val = (float)$val;
|
|
||||||
break;
|
|
||||||
case '(date)=':
|
|
||||||
$op = '$eq';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
case '(date)!=':
|
|
||||||
$op = '$ne';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
case '(date)>':
|
|
||||||
$op = '$gt';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
case '(date)<':
|
|
||||||
$op = '$lt';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
case '(date)>=':
|
|
||||||
$op = '$gte';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
case '(date)<=':
|
|
||||||
$op = '$lte';
|
|
||||||
$dateTime = (new \DateTime($val));
|
|
||||||
$val = new MongoDB\BSON\UTCDatetime($dateTime->getTimestamp() * 1000);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue