示例#1
0
    /**
     * 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.");
        }
    }
示例#2
0
<?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);
示例#3
0
文件: Web.php 项目: Auwibana/babesk
    /**
     * 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!');
        }
    }