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

Commit

Permalink
Merge pull request #1 from ekspress-digital/dev
Browse files Browse the repository at this point in the history
danielmewes#128 and danielmewes#130 bugfixes from dev
  • Loading branch information
ed-piisang authored Jun 29, 2017
2 parents 393a49a + af4146f commit 736a5ad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 0 additions & 1 deletion rdb/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ public function run(Query $query, $options = array(), &$profile = '')
} else {
return $this->createCursorFromResponse($response, $token, $response['n'], $toNativeOptions);
}

}

public function continueQuery($token)
Expand Down
9 changes: 7 additions & 2 deletions rdb/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Cursor implements Iterator
private $currentData;
private $currentSize;
private $currentIndex;
private $totalIndex = 0;
private $isComplete;
private $wasIterated;

Expand Down Expand Up @@ -51,16 +52,19 @@ public function next()
}
$this->wasIterated = true;
$this->currentIndex++;
$this->totalIndex++;
}
public function valid()
{
$this->requestMoreIfNecessary();
return !$this->isComplete || ($this->currentIndex < $this->currentSize);
}

public function key()
{
return null;
return $this->totalIndex;
}

public function current()
{
$this->requestMoreIfNecessary();
Expand All @@ -87,13 +91,14 @@ public function close()
$this->isComplete = true;
}
$this->currentIndex = 0;
$this->totalIndex = 0;
$this->currentSize = 0;
$this->currentData = array();
}

public function bufferedCount()
{
$this->currentSize - $this->currentIndex;
return $this->currentSize - $this->currentIndex;
}

public function getNotes()
Expand Down
14 changes: 12 additions & 2 deletions rdb/Datum/ObjectDatum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

class ObjectDatum extends Datum
{
protected $decimalPoint;

public function __construct($value = null)
{
parent::__construct($value);

$localeconv = localeconv();
$this->decimalPoint = isset($localeconv['decimal_point']) ? $localeconv['decimal_point'] : '.';
}

public function encodeServerRequest()
{
$jsonValue = $this->getValue();
Expand Down Expand Up @@ -70,10 +80,10 @@ public function toNative($opts)
// This is really stupid. It looks like we can either use `date`, which ignores microseconds,
// or we can use `createFromFormat` which cannot handle negative epoch times.
if ($time < 0) {
$format = (strpos($time, '.') !== false) ? 'Y-m-d\TH:i:s.u' : 'Y-m-d\TH:i:s';
$format = (strpos($time, $this->decimalPoint) !== false) ? 'Y-m-d\TH:i:s.u' : 'Y-m-d\TH:i:s';
$datetime = new \DateTime(date($format, $time) . $native['timezone'], new \DateTimeZone('UTC'));
} else {
$format = (strpos($time, '.') !== false) ? '!U.u T' : '!U T';
$format = (strpos($time, $this->decimalPoint) !== false) ? sprintf('!U%su T', $this->decimalPoint) : '!U T';
$datetime = \DateTime::createFromFormat($format, $time . " " . $native['timezone'], new \DateTimeZone('UTC'));
}

Expand Down
1 change: 0 additions & 1 deletion rdb/DatumConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public function canEncodeAsJson($v)
}

return false;

}

public function wrapImplicitVar(Query $q)
Expand Down

0 comments on commit 736a5ad

Please sign in to comment.