예제 #1
0
 public function setUp()
 {
     ActiveRecordModel::getApplication()->clearCachedVars();
     ActiveRecordModel::beginTransaction();
     if (empty($this->autoincrements)) {
         foreach ($this->getUsedSchemas() as $table) {
             $res = $this->db->executeQuery("SHOW TABLE STATUS LIKE '{$table}'");
             $res->next();
             $this->autoincrements[$table] = (int) $res->getInt("Auto_increment");
         }
     }
     if ($this instanceof BackendControllerTestCase) {
         ClassLoader::import('application.model.user.SessionUser');
         ClassLoader::import('application.model.user.UserGroup');
         // set up user
         $group = UserGroup::getNewInstance('Unit tester');
         $group->save();
         $group->setAllRoles();
         $group->save();
         $user = User::getNewInstance('*****@*****.**', null, $group);
         $user->save();
         SessionUser::setUser($user);
     }
     if ($this instanceof ControllerTestCase) {
         $this->request = self::getApplication()->getRequest();
     }
 }
 /**
  * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query.
  * We support two signatures for this method:
  * - $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
  * - $stmt->executeQuery(array($param1, $param2), ResultSet::FETCHMODE_NUM);
  * @param mixed $p1 Either (array) Parameters that will be set using PreparedStatement::set() before query is executed or (int) fetchmode.
  * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC).
  * @return ResultSet
  * @throws SQLException if a database access error occurs.
  */
 public function executeQuery($p1 = null, $fetchmode = null)
 {
     $params = null;
     if ($fetchmode !== null) {
         $params = $p1;
     } elseif ($p1 !== null) {
         if (is_array($p1)) {
             $params = $p1;
         } else {
             $fetchmode = $p1;
         }
     }
     if ($params) {
         for ($i = 0, $cnt = count($params); $i < $cnt; $i++) {
             $this->set($i + 1, $params[$i]);
         }
     }
     $this->updateCount = null;
     // reset
     $sql = $this->replaceParams();
     if ($this->limit > 0 || $this->offset > 0) {
         $this->conn->applyLimit($sql, $this->offset, $this->limit);
     }
     $this->resultSet = $this->conn->executeQuery($sql, $fetchmode);
     return $this->resultSet;
 }
 /**
  * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query.
  * We support two signatures for this method:
  * - $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
  * - $stmt->executeQuery(array($param1, $param2), ResultSet::FETCHMODE_NUM);
  * @param mixed $p1 Either (array) Parameters that will be set using PreparedStatement::set() before query is executed or (int) fetchmode.
  * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC).
  * @return ResultSet
  * @throws SQLException if a database access error occurs.
  */
 public function executeQuery($p1 = null, $fetchmode = null)
 {
     $params = null;
     if ($fetchmode !== null) {
         $params = $p1;
     } elseif ($p1 !== null) {
         if (is_array($p1)) {
             $params = $p1;
         } else {
             $fetchmode = $p1;
         }
     }
     foreach ((array) $params as $i => $param) {
         $this->set($i + 1, $param);
         unset($i, $param);
     }
     unset($params);
     $this->updateCount = null;
     // reset
     $sql = $this->replaceParams();
     if ($this->limit > 0 || $this->offset > 0) {
         $this->conn->applyLimit($sql, $this->offset, $this->limit);
     }
     $this->resultSet = $this->conn->executeQuery($sql, $fetchmode);
     return $this->resultSet;
 }
 /**
  * @see Connection::executeQuery()
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->log("executeQuery(): {$sql}");
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     return $this->childConnection->executeQuery($sql, $fetchmode);
 }
 /**
  * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query.
  * 
  * @param string $sql This method may optionally be called with the SQL statement.
  * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC).
  * @return object Creole::ResultSet
  * @throws SQLException If there is an error executing the specified query.
  * @todo -cStatementCommon Put native query execution logic in statement subclasses.
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->updateCount = null;
     if ($this->limit > 0 || $this->offset > 0) {
         $this->conn->applyLimit($sql, $this->offset, $this->limit);
     }
     $this->resultSet = $this->conn->executeQuery($sql, $fetchmode);
     return $this->resultSet;
 }
예제 #6
0
 /**
  * @see Connection::executeQuery()
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     $startTime = microtime(true);
     $res = $this->childConnection->executeQuery($sql, $fetchmode);
     $endTime = microtime(true);
     $time = $endTime - $startTime;
     $this->log("executeQuery|{$time}|{$sql}");
     return $res;
 }
예제 #7
0
 public static function OnCheckNeuanmeldungen(Connection $conn, ErrorQueue $err)
 {
     $returnvalue = true;
     $jetzt = strtotime("now");
     $q = new DBQuery("SELECT MatrNr FROM neuanmeldung WHERE DeleteAfter < {$jetzt}");
     if ($result = $conn->executeQuery($q)) {
         while ($r = $result->getNextRow()) {
             $delq = new DBQuery("DELETE FROM student WHERE MatrNr=" . $r[0]);
             $delq2 = new DBQuery("DELETE FROM neuanmeldung WHERE MatrNr={$matrnr}");
             if (false == $conn->executeQuery($delq)) {
                 ErrorQueue::SystemErrorConnection("TriggerStudent.php", "OnCheckNeuanmeldungen", $conn);
                 $returnvalue = false;
             }
         }
     } else {
         ErrorQueue::SystemErrorConnection("TriggerStudent.php", "OnCheckNeuanmeldungen", $conn);
         $returnvalue = false;
     }
     return $returnvalue;
 }
예제 #8
0
 private function writepass(Connection $conn, $matrnr, $pass)
 {
     $pass = md5($pass);
     $matrnr = intval($matrnr);
     if ($conn->isConnected()) {
         // Email des Studenten auslesen
         $q = new DBQuery("SELECT Email FROM student WHERE MatrNr={$matrnr}");
         if ($res = $conn->executeQuery($q)) {
             if ($r = $res->getNextRow()) {
                 $email = $r[0];
             } else {
                 $this->last_error = "Die Matrikelnummer existiert nicht.";
                 return false;
             }
         } else {
             $this->last_error = "Die Matrikelnummer konnte nicht &uuml;berpr&uuml;ft werden. " . $conn->getLastError();
             return false;
         }
         // Das neue Passwort wird geschrieben
         $q = new DBQuery("UPDATE student SET Pass='******' WHERE MatrNr={$matrnr}");
         if ($res = $conn->executeQuery($q)) {
             if ($res->affectedRows() > 0) {
                 return $email;
             } else {
                 $this->last_error = "Die Matrikelnummer existiert nicht.";
                 return false;
             }
         } else {
             $this->last_error = "Die Passwort&auml;nderung konnte nicht durchgef&uuml;hrt werden. " . $conn->getLastError();
             return false;
         }
     } else {
         $this->last_error = "Keine Verbindung zur Datenbank.";
         return false;
     }
 }
예제 #9
0
 public static function getUtilisateurAvecLogin($login, $mdp)
 {
     $connexion = new Connection(Config::getDataBaseInfos()['DBname'], Config::getDataBaseInfos()['login'], Config::getDataBaseInfos()['mdp'], null);
     $requete = "SELECT login, mdp, role FROM Utilisateur WHERE login='******'";
     $connexion->executeQuery($requete);
     $result = $connexion->getResults();
     if (count($result) == 0) {
         Config::ajouterErreur("Login ou mot de passe de passe incorrect");
     }
     $result = $result[0];
     if ($result['login'] == $login && $result['mdp'] == $mdp) {
         return self::returnBonTypeUtilisateur($result['login'], $result['role']);
     }
     Config::ajouterErreur("Login ou mot de passe de passe incorrect");
     return null;
 }
예제 #10
0
    /**
     * @brief Resynchronizes all sequences of a database after using INSERTs
     *        without leaving out the auto-incremented column.
     * @param \OC\DB\Connection $conn
     * @return null
     */
    public function resynchronizeDatabaseSequences(Connection $conn)
    {
        $databaseName = $conn->getDatabase();
        foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
            $sequenceName = $sequence->getName();
            $sqlInfo = 'SELECT table_schema, table_name, column_name
				FROM information_schema.columns
				WHERE column_default = ? AND table_catalog = ?';
            $sequenceInfo = $conn->fetchAssoc($sqlInfo, array("nextval('{$sequenceName}'::regclass)", $databaseName));
            $tableName = $sequenceInfo['table_name'];
            $columnName = $sequenceInfo['column_name'];
            $sqlMaxId = "SELECT MAX({$columnName}) FROM {$tableName}";
            $sqlSetval = "SELECT setval('{$sequenceName}', ({$sqlMaxId}))";
            $conn->executeQuery($sqlSetval);
        }
    }
예제 #11
0
 /**
  * @see Connection::executeQuery()
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     $elapsedTime = 0;
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $sqlTimer = sfTimerManager::getTimer('Database');
         $timer = new sfTimer();
     }
     $retval = $this->childConnection->executeQuery($sql, $fetchmode);
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $sqlTimer->addTime();
         $elapsedTime = $timer->getElapsedTime();
     }
     $this->log(sprintf("executeQuery(): [%.2f ms] %s", $elapsedTime * 1000, $sql));
     return $retval;
 }
 /**
  * Cleanup old sessions.
  *
  * @param int The lifetime of a session.
  *
  * @return bool true, if old sessions have been cleaned, otherwise an
  *              exception is thrown.
  *
  * @throws <b>DatabaseException</b> If any old sessions cannot be cleaned.
  */
 public function sessionGC($lifetime)
 {
     // determine deletable session time
     $time = time() - $lifetime;
     // get table/column
     $db_table = $this->getParameterHolder()->get('db_table');
     $db_time_col = $this->getParameterHolder()->get('db_time_col', 'sess_time');
     // delete the record associated with this id
     $sql = 'DELETE FROM ' . $db_table . ' ' . 'WHERE ' . $db_time_col . ' < ' . $time;
     try {
         $this->db->executeQuery($sql);
         return true;
     } catch (SQLException $e) {
         $error = 'Creole SQLException was thrown when trying to manipulate session data. ';
         $error .= 'Message: ' . $e->getMessage();
         throw new sfDatabaseException($error);
     }
 }
 /**
  * @see Connection::executeQuery()
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     $boolLog = sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled') || nyProfiler::getInstance()->isStarted();
     $elapsedTime = 0;
     if ($boolLog) {
         $sqlTimer = sfTimerManager::getTimer('Database');
         $timer = new sfTimer();
     }
     // endif
     $retval = $this->childConnection->executeQuery($sql, $fetchmode);
     if ($boolLog) {
         $sqlTimer->addTime();
         $elapsedTime = $timer->getElapsedTime();
     }
     // endif
     $this->log(sprintf("{sfCreole} executeQuery(): [%.2f ms] %s", $elapsedTime * 1000, $sql), true);
     return $retval;
 }
 public function testRollback()
 {
     $exch = DriverTestManager::getExchange('RecordCount');
     $count_sql = $exch->getSql();
     $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM);
     $rs->next();
     $total = $rs->getInt(1);
     // $this->assertEquals((int) $exch->getResult(), $total);
     $this->conn->setAutoCommit(false);
     // not sure exactly how to test this yet ...
     $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN1');
     $deleted1 = $this->conn->executeUpdate($exch->getSql());
     $exch = DriverTestManager::getExchange('ConnectionTest.setAutoCommit.DELTRAN2');
     $deleted2 = $this->conn->executeUpdate($exch->getSql());
     $this->conn->rollback();
     // compare the actual total w/ what we expect
     $rs = $this->conn->executeQuery($count_sql, ResultSet::FETCHMODE_NUM);
     $rs->next();
     $new_actual_total = $rs->getInt(1);
     $this->assertEquals($total, $new_actual_total, 0, "Failed to find correct (same) num of records in table after rollback().");
     $this->conn->setAutoCommit(true);
 }
예제 #15
0
파일: handler.php 프로젝트: jhmachado/tools
<?php

require_once 'Connection.php';
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$connection = new Connection($request->connection->host, $request->connection->database, $request->connection->user, $request->connection->pass);
if (empty($connection->message)) {
    $connection->executeQuery($request->query);
}
echo json_encode(array('status' => $connection->status, 'message' => $connection->message));
예제 #16
0
 public static function getAlleMitarbeiter(Connection $conn, ErrorQueue $err, UtilBuffer $buffer)
 {
     $q = new DBQuery("SELECT Username, Name, Email, Zugangsstufe FROM mitarbeiter ORDER by Name");
     if ($result = $conn->executeQuery($q)) {
         while ($r = $result->getNextRow()) {
             $mit = new Mitarbeiter($conn);
             $mit->benutzername = $r[0];
             $mit->name = $r[1];
             $mit->email = $r[2];
             $mit->zugangsstufe = $r[3];
             $buffer->add($mit);
         }
         return true;
     } else {
         $err->addError("Die Mitarbeiter konnten nicht ausgelesen werden. " . $conn->getLastError());
     }
     return false;
 }
예제 #17
0
 public static function neuerStudentAnmelden($matrnr, $name, $vorname, $email, $fhemail, ErrorQueue $err, Connection $conn)
 {
     $gen = new PassGenerator();
     $pass = $gen->createNewPass(0);
     $mdpass = md5($pass);
     // Matrikelnummer überprüfen
     $matrnr1 = $matrnr;
     $matrnrlen = strlen($matrnr1);
     $matrnr = intval($matrnr);
     if ($matrnrlen != strlen($matrnr) || $matrnr <= 0) {
         $err->addError("Die Matrikelnummer ist ungültig.");
         return false;
     }
     $name = addslashes($name);
     $email = addslashes($email);
     $vorname = addslashes($vorname);
     $fhemail .= "@stud.fh-luebeck.de";
     $fhemail = addslashes($fhemail);
     if (strcmp($name, "") == 0 || strcmp($vorname, "") == 0 || strcmp($email, "") == 0 || strcmp($fhemail, "") == 0) {
         $err->addError("Bitte f&uuml;ll alle Felder aus.");
         return false;
     }
     if (!Mailer::checkMail($email)) {
         $err->addError("Die E-Mail-Adresse hat das falsche Format.");
         return false;
     }
     if (!Mailer::checkMail($fhemail)) {
         $err->addError("Die FHL-E-Mail-Adresse hat das falsche Format.");
         return false;
     }
     if ($conn->isConnected()) {
         $q = new DBQuery("INSERT INTO student(MatrNr, Name, EMail, Pass, Vorname) VALUES({$matrnr}, '{$name}', '{$email}', '{$mdpass}', '{$vorname}')");
         if ($conn->executeQuery($q)) {
             Mailer::mailit($fhemail, "Deine Anmeldung", "Hallo {$name},\n danke für Deine Anmeldung. Deine Login-Daten lauten:\n Passwort: \"{$pass}\"\nMatrikelnummer: {$matrnr}\n\n" . Studiengang::getSemsysInfo($conn, $err));
             return true;
         } else {
             $err->addError("Die Anmeldung konnte nicht durchgef&uuml;hrt werden. Diese Matrikelnummer ist schon registriert.");
             return false;
         }
         // Query executed
     } else {
         $err->addError("Keine Verbindung zur Datenbank.");
         return false;
     }
     // Connected
 }
예제 #18
0
 public static function setAktiv(Connection $conn, $BrancheID, ErrorQueue $err)
 {
     if (!$conn->isConnected()) {
         $err->addError("Keine Verbindung zur Datenbank.");
         return false;
     }
     $neuerStatus = Branche::STATUS_AKTIV;
     $q = new DBQuery("UPDATE branche SET Status='{$neuerStatus}' WHERE BrancheID='{$BrancheID}'");
     if (!$conn->executeQuery($q)) {
         $err->addError($conn->getLastError());
         return false;
     }
 }
예제 #19
0
 /**
  * Supprime le commentaire d'index $indexCom pour la News d'index $indexNews
  */
 public static function supprimerCommentaire($indexNews, $indexCom)
 {
     $indexNews = Validation::nettoyerIndex($indexNews);
     $indexCom = Validation::nettoyerIndex($indexCom);
     if (empty($indexCom) || empty($indexCom)) {
         Config::ajouterErreur("Probleme d'index de commentaire");
         return;
     }
     $connexion = new Connection(Config::getDataBaseInfos()['DBname'], Config::getDataBaseInfos()['login'], Config::getDataBaseInfos()['mdp'], null);
     $requete = "DELETE FROM Commentaire WHERE indexNews={$indexNews} AND indexCom={$indexCom}";
     $connexion->executeQuery($requete);
 }
예제 #20
0
 public static function abmeldenDozent(Connection $conn, ErrorQueue $err, $dozid)
 {
     $dozid = intval($dozid);
     // Löschen der Anmeldungen zu den Fächern dieses Dozents
     $q = new DBQuery("SELECT PAnfachID FROM angebotenesfach WHERE PDozentID={$dozid}");
     if ($res = $conn->executeQuery($q)) {
         while ($r = $res->getNextRow()) {
             Mailer::mailOnFachFreigabe($conn, $dozid, $r[0]);
             // Studenten benachrichtigen
             $q0 = new DBQuery("DELETE FROM angemeldet WHERE PAnFachID=" . $r[0]);
             if (!$conn->executeQuery($q0)) {
                 $err->addError($conn->getLastError());
             }
         }
     } else {
         $err->addError($conn->getLastError());
         return false;
     }
     // Löschen von angebotenen Fächern und Zugriffsrechten
     $q1 = new DBQuery("DELETE FROM angebotenesfach WHERE PDozentID={$dozid}");
     $q2 = new DBQuery("DELETE FROM dozentlogin WHERE PDozentID={$dozid}");
     if ($conn->executeQuery($q1)) {
         if ($conn->executeQuery($q2)) {
             return true;
         } else {
             $err->addError("Die Zugriffsrechte konnten nicht gel&ouml;scht werden. " . $conn->getLastError());
             return false;
         }
     } else {
         $err->addError("Die angebotenen F&auml;cher konnten nicht gel&ouml;scht werden. " . $conn->getLastError());
         return false;
     }
 }
예제 #21
0
 public static function getSemsysInfo(Connection $conn, ErrorQueue $err)
 {
     $select_query = new DBQuery("SELECT PStudienplanID, Studiengang FROM studienplan ORDER BY Studiengang");
     if (!($studienplaene = $conn->executeQuery($select_query))) {
         $err->addError("Die vorhandenen studienpl&auml;ne konnten von der Datenbank nicht gelesen werden. " . $conn->getLastError());
     }
     if ($studienplaene) {
         $studiengaenge_string = "Folgende Studiengänge nehmen bereits an Studiman teil:\n";
         while ($r = $studienplaene->getNextRow()) {
             $studiengaenge_string .= $r[1] . "\n";
         }
         // while
         $studiengaenge_string .= "\n\n";
     }
     // if
     $string = "Kennst Du schon Studiman?\n" . "Studiman ist ein Tool zur Organisation Deines Semesters an der Fachhochschule Lübeck.\n" . "Deine Benutzerdaten für PRA|VER gelten ebenso für Studiman.\n" . "Schau doch mal rein unter http://osmigib.fh-luebeck.de/SemSys/ .\n\n" . $studiengaenge_string;
     return $string;
 }
예제 #22
0
 public static function enumFreigaben(Connection $conn, ErrorQueue $err)
 {
     $q = new DBQuery("SELECT FreigabeID, FreigabeBereich FROM freigabe ORDER BY FreigabeID");
     if ($conn->isConnected()) {
         if ($result = $conn->executeQuery($q)) {
             return $result;
         } else {
             $err->addError("Datenbankfehler: " . $conn->getLastError());
         }
     } else {
         return false;
     }
 }
예제 #23
0
 /**
  * Method to do selects.
  *
  * @param Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param Connection $con
  * @return array Array of selected Objects
  * @throws PropelException Any exceptions caught during processing will be
  * rethrown wrapped into a PropelException.
  */
 public static function doSelect(Criteria $criteria, $tableName, $con = null)
 {
     $dbMap = Propel::getDatabaseMap($criteria->getDbName());
     $stmt = null;
     try {
         $params = array();
         $sql = self::createSelectSql($criteria, $tableName, $params);
         $sql['params'] = $params;
         $stmt = $con->prepareStatement($sql);
         //$stmt->setLimit($criteria->getLimit());
         $sql['limit'] = $criteria->getLimit();
         //$stmt->setOffset($criteria->getOffset());
         $sql['offset'] = $criteria->getOffset();
         //$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
         $rs = $con->executeQuery($sql, ResultSet::FETCHMODE_NUM);
     } catch (Exception $e) {
         if ($stmt) {
             $stmt->close();
         }
         throw new PropelException($e);
     }
     return $rs;
 }
예제 #24
0
 public static function modifierPerso($index, $nom, $age, $planeteOrigine, $description, $imagePath)
 {
     $index = Validation::nettoyerIndex($index);
     if (empty($index)) {
         Config::ajouterErreur("Probleme d'index de personnage");
         return;
     }
     $nom = Validation::nettoyerString($nom);
     $nImagePath = Validation::nettoyerPath($imagePath);
     $age = Validation::nettoyerString($age);
     $description = Validation::nettoyerString($description);
     $planeteOrigine = Validation::nettoyerString($planeteOrigine);
     if (empty($nom) || empty($age) || empty($planeteOrigine) || empty($description)) {
         Config::ajouterErreur("Erreur de Saisie, Champ Incorrect pour la modification d'un personnage");
         return;
     }
     $connexion = new Connection(Config::getDataBaseInfos()['DBname'], Config::getDataBaseInfos()['login'], Config::getDataBaseInfos()['mdp'], null);
     $requete = "UPDATE Personnage SET nom='{$nom}', age='{$age}', planeteOrigine='{$planeteOrigine}', description='{$description}', imagePath='{$nImagePath}' WHERE indexPerso={$index}";
     $connexion->executeQuery($requete);
 }
예제 #25
0
 /**
  * Execute this migration version up or down and and return the SQL.
  *
  * @param string $direction   The direction to execute the migration.
  * @param string $dryRun      Whether to not actually execute the migration SQL and just do a dry run.
  * @return array $sql
  * @throws Exception when migration fails
  */
 public function execute($direction, $dryRun = false)
 {
     $this->_sql = array();
     $this->_connection->beginTransaction();
     try {
         $start = microtime(true);
         $this->_state = self::STATE_PRE;
         $fromSchema = $this->_sm->createSchema();
         $this->_migration->{'pre' . ucfirst($direction)}($fromSchema);
         if ($direction === 'up') {
             $this->_outputWriter->write("\n" . sprintf('  <info>++</info> migrating <comment>%s</comment>', $this->_version) . "\n");
         } else {
             $this->_outputWriter->write("\n" . sprintf('  <info>--</info> reverting <comment>%s</comment>', $this->_version) . "\n");
         }
         $this->_state = self::STATE_EXEC;
         $toSchema = clone $fromSchema;
         $this->_migration->{$direction}($toSchema);
         $this->addSql($fromSchema->getMigrateToSql($toSchema, $this->_platform));
         if ($dryRun === false) {
             if ($this->_sql) {
                 $count = count($this->_sql);
                 foreach ($this->_sql as $query) {
                     $this->_outputWriter->write('     <comment>-></comment> ' . $query);
                     $this->_connection->executeQuery($query);
                 }
             } else {
                 $this->_outputWriter->write(sprintf('<error>Migration %s was executed but did not result in any SQL statements.</error>', $this->_version));
             }
             if ($direction === 'up') {
                 $this->markMigrated();
             } else {
                 $this->markNotMigrated();
             }
         } else {
             foreach ($this->_sql as $query) {
                 $this->_outputWriter->write('     <comment>-></comment> ' . $query);
             }
         }
         $this->_state = self::STATE_POST;
         $this->_migration->{'post' . ucfirst($direction)}($toSchema);
         $end = microtime(true);
         $this->_time = round($end - $start, 2);
         if ($direction === 'up') {
             $this->_outputWriter->write(sprintf("\n  <info>++</info> migrated (%ss)", $this->_time));
         } else {
             $this->_outputWriter->write(sprintf("\n  <info>--</info> reverted (%ss)", $this->_time));
         }
         $this->_connection->commit();
         return $this->_sql;
     } catch (SkipMigrationException $e) {
         $this->_connection->rollback();
         // now mark it as migrated
         if ($direction === 'up') {
             $this->markMigrated();
         } else {
             $this->markNotMigrated();
         }
         $this->_outputWriter->write(sprintf("\n  <info>SS</info> skipped (Reason: %s)", $e->getMessage()));
     } catch (\Exception $e) {
         $this->_outputWriter->write(sprintf('<error>Migration %s failed during %s. Error %s</error>', $this->_version, $this->getExecutionState(), $e->getMessage()));
         $this->_connection->rollback();
         $this->_state = self::STATE_NONE;
         throw $e;
     }
     $this->_state = self::STATE_NONE;
 }
예제 #26
0
 public static function modifierNews($index, $titre, $pathImage, $resume, $contenu)
 {
     $index = Validation::nettoyerIndex($index);
     if (empty($index)) {
         Config::ajouterErreur("Probleme d'index d'actualité pour la modification");
         return;
     }
     $titre = Validation::nettoyerString($titre);
     $nPathImage = Validation::nettoyerPath($pathImage);
     $resume = Validation::nettoyerString($resume);
     $contenu = Validation::nettoyerString($contenu);
     if (empty($titre) || empty($resume) || empty($contenu)) {
         Config::ajouterErreur("Erreur de Saisie, Champ Incorrect pour la modification");
         return;
     }
     $connexion = new Connection(Config::getDataBaseInfos()['DBname'], Config::getDataBaseInfos()['login'], Config::getDataBaseInfos()['mdp'], null);
     $requete = "UPDATE News SET titre='{$titre}', pathImage='{$nPathImage}', resume='{$resume}', contenu='{$contenu}' WHERE indexNews={$index}";
     $connexion->executeQuery($requete);
 }
예제 #27
0
 public function rollback()
 {
     $this->connection->executeQuery('ROLLBACK');
     $this->connection->close();
     Transaction::$transactions->removeLast();
 }
예제 #28
0
 public static function enumGroessen(Connection $conn, ErrorQueue $err)
 {
     $q = new DBQuery("SELECT UnternehmensgroesseID, Mitarbeiterzahl, MindestName FROM unternehmensgroesse");
     if ($conn->isConnected()) {
         if ($result = $conn->executeQuery($q)) {
             return $result;
         } else {
             $err->addError("Datenbankfehler: " . $conn->getLastError());
         }
     } else {
         return false;
     }
 }