Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Statement recreation searches the cursor position is its not at 0; Add switch-case block to handle reconnecting pre-tasks of basic PDOStatement calls; Fix namespace Legow to LegoW;
- Loading branch information
1 parent
7a357cc
commit 89df08d
Showing
14 changed files
with
413 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/vendor/ | ||
/tmp/ | ||
/test/configuration.xml | ||
/test/configuration.xml | ||
/phpunit-xdebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
[![Build Status](https://travis-ci.org/adamturcsan/reconnecting-pdo.svg?branch=master)](https://travis-ci.org/adamturcsan/reconnecting-pdo) | ||
[![Coverage Status](https://coveralls.io/repos/github/adamturcsan/reconnecting-pdo/badge.svg?branch=feature%2Freconnecting-statement)](https://coveralls.io/github/adamturcsan/reconnecting-pdo?branch=feature%2Freconnecting-statement) | ||
# reconnecting-pdo | ||
PDO object which can reconnect if server has gone away |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* LegoW\ReconnectingPDO (https://github.com/adamturcsan/reconnecting-pdo) | ||
* | ||
* @copyright Copyright (c) 2014-2016 Legow Hosting Kft. (http://www.legow.hu) | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
*/ | ||
|
||
namespace LegoW\ReconnectingPDO; | ||
|
||
/** | ||
* Description of CursorException | ||
* | ||
* @author Turcsán Ádám <turcsan.adam@legow.hu> | ||
*/ | ||
class CursorException extends \Exception | ||
{ | ||
//put your code here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* LegoW\ReconnectingPDO (https://github.com/adamturcsan/reconnecting-pdo) | ||
* | ||
* @copyright Copyright (c) 2014-2016 Legow Hosting Kft. (http://www.legow.hu) | ||
* @license https://opensource.org/licenses/MIT MIT License | ||
*/ | ||
|
||
namespace LegoW\ReconnectingPDO; | ||
|
||
use LegoW\ReconnectingPDO\CursorException; | ||
/** | ||
* Description of StatementCursor | ||
* | ||
* @author Turcsán Ádám <turcsan.adam@legow.hu> | ||
*/ | ||
class StatementCursor | ||
{ | ||
/** | ||
* Current cursor position | ||
* @var int | ||
*/ | ||
private $position = 0; | ||
|
||
public function getPosition() | ||
{ | ||
return $this->position; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function next() | ||
{ | ||
$this->position++; | ||
return $this; | ||
} | ||
/** | ||
* | ||
* @return $this | ||
* @throws CursorException | ||
*/ | ||
public function prev() | ||
{ | ||
if($this->getPosition() == 0) { | ||
throw new CursorException("Position cannot be less than zero"); | ||
} | ||
$this->position--; | ||
return $this; | ||
} | ||
|
||
public function setPosition($position) | ||
{ | ||
$direction = $position < $this->position ? -1 : 1; | ||
while($this->position != $position) { | ||
$this->position += $direction; | ||
} | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.