jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
532 stars 137 forks source link

Transaction error handling not working #124

Closed sarathsprakash closed 10 years ago

sarathsprakash commented 10 years ago

I tried to use $transaction->isError() and $transaction->isClosed in neo4j transaction, but these functions failed to catch the error. Here is my code, where I did the transaction roll-back after committing, which according to the documentation should produce an error and it should be handled by isClosed(), but it never handled the error rather produced the error.

code

    require("vendor/autoload.php");
    use Everyman\Neo4j\Cypher\Query;
    $client = new Everyman\Neo4j\Client();

    $transaction = $client->beginTransaction();

    $queryA = new Query($client, 'CREATE (n:testing{id:189})');
    $result = $transaction->addStatements($queryA);
    $transaction->commit();
    $transaction->rollback(); // performing rollback after commit
    if ($transaction->isClosed()) {
    echo "No more statements can be added!";
    }

Error

Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Transaction is already closed' in C:\xampp\htdocs\feed\vendor\everyman\neo4jphp\lib\Everyman\Neo4j\Transaction.php on line 149

But actually this error should be handled by $transaction->isClosed(),but it didin't, please help, thanks in advance

Link to stackoverflow - http://stackoverflow.com/questions/22118933/transaction-error-handling-not-working-neo4jphp

jadell commented 10 years ago

This isn't a bug. You don't need to rollback after the commit. I've answered the question on stackoverflow.