From 813ecf397f473274151c49b7708d66e0507536c1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 9 Sep 2015 23:27:53 +0200 Subject: [PATCH] new QI object for sql installations, some tests with it + adjustments towards it --- db/connection/Connection.php | 15 ++++++++------- db/connection/ConnectionAbstr.php | 3 ++- db/connection/ConnectionMYS.php | 18 ++++++++++++++---- db/qq/QI.php | 30 ++++++++++++++++++++++++++++++ dbd/autoload.inc | 3 ++- dbd/qt/INSTALL_SAI.php | 10 ++++++++++ system/path.php | 5 +++++ 7 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 db/qq/QI.php create mode 100644 dbd/qt/INSTALL_SAI.php diff --git a/db/connection/Connection.php b/db/connection/Connection.php index 84f498e..029f604 100644 --- a/db/connection/Connection.php +++ b/db/connection/Connection.php @@ -1,16 +1,11 @@ dbinfo = $dbinfo; if(!$dbinfo){ $dbinfo = \SYSTEM\system::getSystemDBInfo();} @@ -44,4 +39,10 @@ class Connection extends ConnectionAbstr{ public function exec($query){ return $this->connection->exec($query);} + + public function trans(){ + return $this->connection->trans();} + + public function commit(){ + return $this->connection->commit();} } \ No newline at end of file diff --git a/db/connection/ConnectionAbstr.php b/db/connection/ConnectionAbstr.php index 258bc8d..7346e43 100644 --- a/db/connection/ConnectionAbstr.php +++ b/db/connection/ConnectionAbstr.php @@ -13,7 +13,8 @@ abstract class ConnectionAbstr { abstract public function prepare($stmtName, $stmt, $values); //Query Database with normal Statement with $query = SQLString abstract public function query($query); - + abstract public function commit(); + abstract public function trans(); //Convert Prepared Values to SQL Type identifiers protected static function getPrepareValueType($value){ if(is_double($value)){ diff --git a/db/connection/ConnectionMYS.php b/db/connection/ConnectionMYS.php index 79ac95f..3d2b422 100644 --- a/db/connection/ConnectionMYS.php +++ b/db/connection/ConnectionMYS.php @@ -1,7 +1,5 @@ connection);} public function query($query){ - $result = mysqli_query($this->connection, $query); + $result = \mysqli_query($this->connection, $query); if(!$result){ - throw new \Exception('Could not query Database. Check ur Query Syntax or required Rights: '.mysqli_error($this->connection));} + throw new \Exception('Could not query Database. Check ur Query Syntax or required Rights: '.\mysqli_error($this->connection));} if($result === TRUE){ return TRUE;} return new ResultMysqli($result); } + + public function commit(){ + if(!\mysqli_commit($this->connection)){ + throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));} + return true; + } + + public function trans(){ + if(!\mysqli_begin_transaction($this->connection,MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT)){ + throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));} + return true; + } } \ No newline at end of file diff --git a/db/qq/QI.php b/db/qq/QI.php new file mode 100644 index 0000000..668fc7c --- /dev/null +++ b/db/qq/QI.php @@ -0,0 +1,30 @@ +m_host. + ' --user=' . $dbinfo->m_user. + ' --password=' . $dbinfo->m_password. + ' --database=' . $dbinfo->m_database. + ' --execute="SOURCE '; + $result = array(); + foreach($files as $file){ + $result[] = shell_exec($command .$file. '"');} + return \SYSTEM\LOG\JsonResult::toString($result); + } +} \ No newline at end of file diff --git a/dbd/autoload.inc b/dbd/autoload.inc index 3cfa7e3..342d9b8 100644 --- a/dbd/autoload.inc +++ b/dbd/autoload.inc @@ -1,3 +1,4 @@