PDO_SQLite Transactions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've been having this problem for a while now,
when I use transactions in SQLite with PDO it stalls on me with an error stating my statements are in progress. I've tried closing all cursors to my statements, but that does not seem to resolve this for me. This is my code,
(obviously shortened quite a bit)

I hope someone could help me figure out what's going wrong, could it be that I can't run an update yet because
the transaction has not been commited yet?? (sounds a bit odd to me)

<?php
// setup an SQLite db connection via PDO, this is in $db
try {
// $fileName, $fileDesc and $fileType are all existing, cleaned, checked values $statement = $db->prepare('INSERT INTO Files (file_name, file_desc, file_type, file_filename) VALUES (?, ?, ?, ?)');
	$statement->execute(array($fileName, $fileDesc, $fileType, ''));

	$id = $db->lastInsertId();

	$statement->closeCursor();

	$res = move_uploaded_file($tmp_file, $new_file);

	if($res === false) {
	    $db->rollBack();

	    echo 'error';
	    exit;
	} else {
$statement = $db->prepare('UPDATE Files SET file_filename=? WHERE file_id=?');
	    $statement->execute(array($new_file, $id));

	    $statement->closeCursor();

	    OG::$db->commit();
	}
} catch(Exception $e) {
    var_dump($e);
}

And the Exception I recieve (there is only one commit in the file, due to shortening for posting
the line listed here is incorrect):

object(PDOException)#7 (7) {
  ["message:protected"]=>
string(88) "SQLSTATE[HY000]: General error: 1 cannot commit transaction - SQL statements in progress"
  ["string:private"]=>
  string(0) ""
  ["code:protected"]=>
  string(5) "HY000"
  ["file:protected"]=>
  string(43) "/home/tularis/public_html/t/createFile.php"
  ["line:protected"]=>
  int(95)
  ["trace:private"]=>
  array(1) {
    [0]=>
    array(6) {
      ["file"]=>
      string(43) "/home/tularis/public_html/t/createFile.php"
      ["line"]=>
      int(95)
      ["function"]=>
      string(6) "commit"
      ["class"]=>
      string(3) "PDO"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(0) {
      }
    }
  }
  ["errorInfo"]=>
  array(3) {
    [0]=>
    string(5) "HY000"
    [1]=>
    int(1)
    [2]=>
    string(54) "cannot commit transaction - SQL statements in progress"
  }
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux