Esempio n. 1
0
 /**
  * @param bool $resetConnection bedeutet hier das DBAL Object Connection. die PDO Connection wird wiederverwendet (wenn möglich)
  * @return Doctrine\ORM\EntityManager
  */
 public function getEntityManager($con = NULL, $reset = FALSE, $resetConnection = FALSE)
 {
     if (!isset($con)) {
         $con = $this->getConnectionName();
     }
     if (!isset($this->entityManagers[$con]) || $reset) {
         // wenn reset ist und wir noch eine offene connection haben, wollen wir diese nehmen
         if ($resetConnection) {
             $connection = $this->getConnectionOptions($con);
             if (isset($this->entityManagers[$con])) {
                 // benutzt die alte PDO low-level connection
                 $dbalConnection = $this->entityManagers[$con]->getConnection();
                 if ($dbalConnection->isTransactionActive()) {
                     $dbalConnection->rollback();
                 }
                 $connection['pdo'] = $dbalConnection->getWrappedConnection();
             }
         } elseif ($reset && isset($this->entityManagers[$con])) {
             $connection = $this->entityManagers[$con]->getConnection();
             // benutze das DBAL/Connection Object der "alten" Verbindung
         } else {
             $connection = $this->getConnectionOptions($con);
         }
         $entityManager = $this->entityManagers[$con] = EntityManager::create($connection, $this->getConfiguration());
         $platform = $entityManager->getConnection()->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('enum', 'string');
         if (($cset = $this->project->getConfiguration()->get(array('db', $con, 'charset'), 'utf8')) != NULL) {
             // take NAMES not SET CHARACTER SET
             // http://dev.mysql.com/doc/refman/5.1/de/charset-connection.html
             // set character set, sets the character_set_connection to the collation of the db (when this is wrong everything does not go well)
             $entityManager->getConnection()->query("SET NAMES '" . $cset . "'");
         }
         $this->manager->dispatchEvent('Psc.Doctrine.initEntityManager', (object) array('module' => $this), $entityManager);
     }
     return $this->entityManagers[$con];
 }
Esempio n. 2
0
 /**
  * @return Response des Aufrufes
  */
 public function process()
 {
     if (!isset($this->url) || $this->url === '') {
         throw new RequestException('Request kann nicht gesendet werden. URL ist leer');
     }
     //if (curl_getopt($this->ch, CURLOPT_URL) == '') throw new RequestException('Request kann nicht gesendet werden. wurde vorher init() aufgerufen? (CURLOPT_URL nicht gesetzt).');
     /* speicher die responseHeaders in unserer variable die wir an die response weitergeben */
     $this->setOption(CURLOPT_HEADERFUNCTION, array($this, 'callbackHeader'));
     $this->responseHeader = NULL;
     /* Ausführen */
     $rawResponse = curl_exec($this->ch);
     if (curl_error($this->ch) != "") {
         throw new RequestException(sprintf("Fehler beim Aufruf von URL: '%s' CURL-Error: '%s'", $this->url, curl_error($this->ch)), curl_errno($this->ch));
     }
     try {
         $this->response = new Response($rawResponse, HTTP\Header::parse($this->responseHeader));
     } catch (\Psc\Exception $e) {
         throw new RequestException('Aus dem Request konnte keine Response erstellt werden. ' . $e->getMessage(), 0, $e);
     }
     $this->headers = curl_getinfo($this->ch, CURLINFO_HEADER_OUT);
     curl_close($this->ch);
     $this->manager->dispatchEvent(self::EVENT_PROCESSED, array('response' => $this->response, 'headers' => $this->headers), $this);
     return $rawResponse;
 }