--- /dev/null
+<?php
+
+class PdoPatchManager extends AbstractPdoManager {
+
+ public function patchExists($version_id_from,$version_id_to){
+ $sql = "SELECT * FROM patches WHERE version_id_from=? AND version_id_to=?";
+ return $this->queryOne($sql,$version_id_from,$version_id_to);
+ }
+
+ public function edit(Patch $patch){
+ if ($patch->id){
+ $this->update($patch);
+ return $patch->id;
+ } else {
+ return $this->create($patch);
+ }
+ }
+
+ public function create(Patch $patch){
+ $sql = "INSERT INTO patches(version_id_from, version_id_to, script_content, script_name) VALUES (?,?,?,?)";
+ $this->query($sql,$patch->version_id_from,$patch->version_id_to,$patch->script_content,$patch->script_name);
+ return $this->lastInsertId();
+ }
+
+ public function update(Patch $patch){
+ $sql = "UPDATE patches SET version_id_from=?,version_id_to=?,script_content=?,script_name=?";
+ $this->query($sql,$patch->version_id_from,$patch->version_id_to,$patch->script_content,$patch->script_name);
+ }
+
+ public function delete($id){
+ $sql = "DELETE FROM patches WHERE id=?";
+ $this->query($sql,$id);
+ }
+
+ public function getInfo($id){
+ $sql = "SELECT * FROM patches WHERE id=?";
+ return $this->queryOne($sql,$id);
+ }
+
+ public function getListByVersionTo($version_id_to){
+ $sql = "SELECT id,version_id_from,version_id_to,script_name FROM patches WHERE version_id_to=?";
+ return $this->query($sql,$version_id_to);
+ }
+
+}