* Missed from refactoring pull

This commit is contained in:
Momchil Bozhinov
2021-02-23 12:09:34 +02:00
parent 781d53d1cd
commit 11fade70ef
2 changed files with 14 additions and 5 deletions

View File

@@ -2492,10 +2492,12 @@ class ClonOS {
[$this->form['pkg_vm_cpus']],
[$owner]
));
if($res===false) return $this->messageError('sql error!');
if(!$res['error']) return $this->messageSuccess($res);
return $this->messageError('sql error!',$res);
if($res['error'] == false){
return $this->messageSuccess($res);
} else {
return $this->messageError('sql error!',$res);
}
}
function ccmd_vmTemplateEditInfo(){

View File

@@ -161,6 +161,7 @@ class Db {
function insert($sql, $values){
try {
$this->_pdo->beginTransaction();
$query = $this->_pdo->prepare($sql);
$i = 1;
foreach($values as $v){
@@ -172,15 +173,19 @@ class Db {
$i++;
}
$query->execute();
$lastId = $this->_pdo->lastInsertId();
$this->_pdo->commit();
} catch(PDOException $e) {
$this->_pdo->rollBack();
#throw new Exception($e->getMessage());
return array('error'=>true,'info'=>$e->getMessage());
}
return array('error'=>false,'lastID'=>$query->lastInsertId());
return array('error'=>false,'lastID'=>$lastId);
}
function update($sql, $values){
try {
$this->_pdo->beginTransaction();
$query = $this->_pdo->prepare($sql);
$i = 1;
foreach($values as $v){
@@ -195,7 +200,9 @@ class Db {
$rowCount=$query->rowCount();
$this->_pdo->commit();
} catch(PDOException $e) {
return false;//$e->getMessage();
$this->_pdo->rollBack();
#return false;
throw new Exception($e->getMessage());
}
return array('rowCount'=>$rowCount);
}