This commit is contained in:
kaetemi 2014-09-03 06:08:08 +02:00
commit 4982e7c6c4

View file

@ -127,8 +127,7 @@ class DBLayer {
$field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc)));
try {
$sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" );
foreach ( $data as $key => $value )
{
foreach ($data as $key => $value) {
$sth->bindValue( ":$key", $value );
}
$this->PDO->beginTransaction();
@ -138,7 +137,7 @@ class DBLayer {
}
catch (Exception $e) {
// for rolling back the changes during transaction
// $this -> PDO -> rollBack();
$this->PDO->rollBack();
throw $e; // new Exception( "error in inseting" );
}
return $lastId;
@ -210,12 +209,9 @@ class DBLayer {
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$this -> PDO -> beginTransaction();
$sth->execute();
$this -> PDO -> commit();
}
catch (Exception $e) {
$this->PDO->rollBack();
throw $e; // new Exception( 'error in updating' );
return false;
}
@ -238,14 +234,9 @@ class DBLayer {
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$this->PDO->beginTransaction();
// execution
$sth->execute();
$this->PDO->commit();
}
catch (Exception $e) {
// for rolling back the changes during transaction
$this->PDO->rollBack();
throw $e; // new Exception("error in inserting");
}
}
@ -262,12 +253,9 @@ class DBLayer {
$this->useDb();
try {
$sth = $this->PDO->prepare("DELETE FROM $tb_name WHERE $where");
$this->PDO->beginTransaction();
$sth->execute($data);
$this->PDO->commit();
}
catch (Exception $e) {
$this->PDO->rollBack();
throw $e; // new Exception( "error in deleting" );
}
}