Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit 736a5ad

Browse files
author
ed-piisang
authored
Merge pull request #1 from ekspress-digital/dev
danielmewes#128 and danielmewes#130 bugfixes from dev
2 parents 393a49a + af4146f commit 736a5ad

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

rdb/Connection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ public function run(Query $query, $options = array(), &$profile = '')
271271
} else {
272272
return $this->createCursorFromResponse($response, $token, $response['n'], $toNativeOptions);
273273
}
274-
275274
}
276275

277276
public function continueQuery($token)

rdb/Cursor.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Cursor implements Iterator
1717
private $currentData;
1818
private $currentSize;
1919
private $currentIndex;
20+
private $totalIndex = 0;
2021
private $isComplete;
2122
private $wasIterated;
2223

@@ -51,16 +52,19 @@ public function next()
5152
}
5253
$this->wasIterated = true;
5354
$this->currentIndex++;
55+
$this->totalIndex++;
5456
}
5557
public function valid()
5658
{
5759
$this->requestMoreIfNecessary();
5860
return !$this->isComplete || ($this->currentIndex < $this->currentSize);
5961
}
62+
6063
public function key()
6164
{
62-
return null;
65+
return $this->totalIndex;
6366
}
67+
6468
public function current()
6569
{
6670
$this->requestMoreIfNecessary();
@@ -87,13 +91,14 @@ public function close()
8791
$this->isComplete = true;
8892
}
8993
$this->currentIndex = 0;
94+
$this->totalIndex = 0;
9095
$this->currentSize = 0;
9196
$this->currentData = array();
9297
}
9398

9499
public function bufferedCount()
95100
{
96-
$this->currentSize - $this->currentIndex;
101+
return $this->currentSize - $this->currentIndex;
97102
}
98103

99104
public function getNotes()

rdb/Datum/ObjectDatum.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
class ObjectDatum extends Datum
1010
{
11+
protected $decimalPoint;
12+
13+
public function __construct($value = null)
14+
{
15+
parent::__construct($value);
16+
17+
$localeconv = localeconv();
18+
$this->decimalPoint = isset($localeconv['decimal_point']) ? $localeconv['decimal_point'] : '.';
19+
}
20+
1121
public function encodeServerRequest()
1222
{
1323
$jsonValue = $this->getValue();
@@ -70,10 +80,10 @@ public function toNative($opts)
7080
// This is really stupid. It looks like we can either use `date`, which ignores microseconds,
7181
// or we can use `createFromFormat` which cannot handle negative epoch times.
7282
if ($time < 0) {
73-
$format = (strpos($time, '.') !== false) ? 'Y-m-d\TH:i:s.u' : 'Y-m-d\TH:i:s';
83+
$format = (strpos($time, $this->decimalPoint) !== false) ? 'Y-m-d\TH:i:s.u' : 'Y-m-d\TH:i:s';
7484
$datetime = new \DateTime(date($format, $time) . $native['timezone'], new \DateTimeZone('UTC'));
7585
} else {
76-
$format = (strpos($time, '.') !== false) ? '!U.u T' : '!U T';
86+
$format = (strpos($time, $this->decimalPoint) !== false) ? sprintf('!U%su T', $this->decimalPoint) : '!U T';
7787
$datetime = \DateTime::createFromFormat($format, $time . " " . $native['timezone'], new \DateTimeZone('UTC'));
7888
}
7989

rdb/DatumConverter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ public function canEncodeAsJson($v)
158158
}
159159

160160
return false;
161-
162161
}
163162

164163
public function wrapImplicitVar(Query $q)

0 commit comments

Comments
 (0)