<?php

require __DIR__ . '/../vendor/autoload.php';
$db_dsn = 'mysql:host=localhost;dbname=mypoll;charset=utf8';
$db_user = '******';
$db_pass = '******';
$db_options = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
RedBeanPHP\Facade::setup($db_dsn, $db_user, $db_pass);
$templatePathDir = 'template/';
Exemplo n.º 2
0
        $pdo->exec('SET CHARACTER SET utf8');
        $pdo->exec('SET CHARACTER_SET_CONNECTION = utf8');
        $pdo->exec('SET CHARACTER_SET_DATABASE = utf8');
        $pdo->exec('SET character_set_results = utf8');
        $pdo->exec('SET character_set_server = utf8');
        $pdo->exec('SET SESSION interactive_timeout = 28800');
        $pdo->exec('SET SESSION wait_timeout = 28800');
    }
    return $pdo;
};
$di['db'] = function () use($di) {
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'rb.php';
    R::setup($di['pdo']);
    $helper = new Box_BeanHelper();
    $helper->setDi($di);
    $mapper = new \RedBeanPHP\Facade();
    $mapper->getRedBean()->setBeanHelper($helper);
    $freeze = isset($di['config']['db']['freeze']) ? (bool) $di['config']['db']['freeze'] : true;
    $mapper->freeze($freeze);
    $db = new Box_Database();
    $db->setDi($di);
    $db->setDataMapper($mapper);
    return $db;
};
$di['pager'] = function () use($di) {
    $service = new Box_Pagination();
    $service->setDi($di);
    return $service;
};
$di['url'] = function () use($di) {
    $url = new Box_Url();