Added update method to database class
This commit is contained in:
@@ -52,7 +52,8 @@ class HandBrakeCluster_Database {
|
|||||||
|
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new HandBrakeCluster_Exception_DatabaseQueryFailed();
|
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||||
|
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stmt->fetchAll();
|
return $stmt->fetchAll();
|
||||||
@@ -83,17 +84,49 @@ class HandBrakeCluster_Database {
|
|||||||
|
|
||||||
if ($bind_params) {
|
if ($bind_params) {
|
||||||
foreach ($bind_params as $param) {
|
foreach ($bind_params as $param) {
|
||||||
|
if (isset($param['type'])) {
|
||||||
$stmt->bindValue(':'.$param['name'], $param['value'], $param['type']);
|
$stmt->bindValue(':'.$param['name'], $param['value'], $param['type']);
|
||||||
|
} else {
|
||||||
|
$stmt->bindValue(':'.$param['name'], $param['value']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stmt->execute();
|
$result = $stmt->execute();
|
||||||
|
if (!$result) {
|
||||||
|
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||||
|
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($sql, $bind_params = null) {
|
||||||
|
$stmt = $this->dbh->prepare($sql);
|
||||||
|
|
||||||
|
if ($bind_params) {
|
||||||
|
foreach ($bind_params as $param) {
|
||||||
|
if (isset($param['type'])) {
|
||||||
|
$stmt->bindValue(':'.$param['name'], $param['value'], $param['type']);
|
||||||
|
} else {
|
||||||
|
$stmt->bindValue(':'.$param['name'], $param['value']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $stmt->execute();
|
||||||
|
if (!$result) {
|
||||||
|
list($code, $dummy, $message) = $stmt->errorInfo();
|
||||||
|
throw new HandBrakeCluster_Exception_DatabaseQueryFailed($message, $code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function errorInfo() {
|
public function errorInfo() {
|
||||||
return $this->dbh->errorInfo();
|
return $this->dbh->errorInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function lastInsertId() {
|
||||||
|
return $this->dbh->lastInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user