/** * Initializes the PDO-Object, used for Database-Queries * * triggers an error when */ private function initDatabaseConnections() { try { $connector = new DBConnect(); $connector->initDatabaseFromXML(); $this->_pdo = $connector->getPdo(); $this->_em = $connector->getDoctrineEntityManager(); $this->_pdo->query('SET @activeSchoolyear := (SELECT ID FROM SystemSchoolyears WHERE active = "1" LIMIT 1); '); } catch (PDOException $e) { echo $e->getMessage(); die("Sorry, could not connect to the database with pdo."); } }
<?php use Doctrine\ORM\Tools\Console\ConsoleRunner; require_once dirname(__FILE__) . '/../../path.php'; require_once '../../sql_access/DBConnect.php'; $connect = new DBConnect(); $connect->initDatabaseFromXml(); $entityManager = $connect->getDoctrineEntityManager(); // replace with mechanism to retrieve EntityManager in your app //$entityManager = GetEntityManager(); return ConsoleRunner::createHelperSet($entityManager);
/** * Initializes the PDO-Object, used for Database-Queries * * triggers an error when the PDO-Object could not be created */ private function initDatabaseConnections() { try { $connector = new DBConnect(); $connector->initDatabaseFromXML(); $this->_pdo = $connector->getPdo(); $this->_em = $connector->getDoctrineEntityManager(); $this->_pdo->query('SET @activeSchoolyear := (SELECT ID FROM SystemSchoolyears WHERE active = "1");'); } catch (Exception $e) { trigger_error('Could not create the PDO-Object!'); } }