|
|
|
@ -127,18 +127,13 @@ 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();
|
|
|
|
|
$sth->execute();
|
|
|
|
|
$lastId = $this->PDO->lastInsertId();
|
|
|
|
|
$this -> PDO -> commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception $e) {
|
|
|
|
|
// for rolling back the changes during transaction
|
|
|
|
|
// $this -> PDO -> rollBack();
|
|
|
|
|
throw $e; // new Exception( "error in inseting" );
|
|
|
|
|
}
|
|
|
|
|
return $lastId;
|
|
|
|
@ -210,12 +205,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 +230,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 +249,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" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|