Added db connection
This commit is contained in:
parent
10c8093ed5
commit
75c0442e9a
@ -2,7 +2,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.0",
|
"php": ">=5.5.0",
|
||||||
"slim/slim": "^3.1",
|
"slim/slim": "^3.1",
|
||||||
"slim/php-view": "^2.0"
|
"slim/php-view": "^2.0",
|
||||||
|
"vrana/notorm": "dev-master"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"process-timeout" : 0
|
"process-timeout" : 0
|
||||||
|
45
composer.lock
generated
45
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "37fe8b36d00a40955cbd52e4949aa8f1",
|
"content-hash": "ca8f6133814e92e4e70538a15c4b1a32",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "container-interop/container-interop",
|
"name": "container-interop/container-interop",
|
||||||
@ -343,12 +343,53 @@
|
|||||||
"router"
|
"router"
|
||||||
],
|
],
|
||||||
"time": "2016-12-20T20:30:47+00:00"
|
"time": "2016-12-20T20:30:47+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vrana/notorm",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/vrana/notorm.git",
|
||||||
|
"reference": "e49d5d2f1bfe440dc82b61f46172635dfcb6f6dd"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/vrana/notorm/zipball/e49d5d2f1bfe440dc82b61f46172635dfcb6f6dd",
|
||||||
|
"reference": "e49d5d2f1bfe440dc82b61f46172635dfcb6f6dd",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"NotORM.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"Apache-2.0",
|
||||||
|
"GPL-2.0+"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jakub Vrána",
|
||||||
|
"homepage": "http://www.vrana.cz/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "NotORM is a PHP library for simple working with data in the database.",
|
||||||
|
"homepage": "http://www.notorm.com/",
|
||||||
|
"keywords": [
|
||||||
|
"database",
|
||||||
|
"dbal"
|
||||||
|
],
|
||||||
|
"time": "2014-10-30 16:55:08"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": {
|
||||||
|
"vrana/notorm": 20
|
||||||
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
@ -60,6 +60,32 @@ $container['renderer'] = function ($c) {
|
|||||||
return new Slim\Views\PhpRenderer($settings['template_path']);
|
return new Slim\Views\PhpRenderer($settings['template_path']);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add the database layer
|
||||||
|
/**
|
||||||
|
* ==============
|
||||||
|
* INSTRUCTIEBLOK
|
||||||
|
* ==============
|
||||||
|
*
|
||||||
|
* Je kunt de database gebruiken in je code via $this->db. Vermijd het direct gebruiken van het PDO object via $this->get('db.pdo').
|
||||||
|
* Je kunt hiervoor beter de ingebouwde functies van NotORM gebruiken.
|
||||||
|
*/
|
||||||
|
$container['db.pdo'] = function ($c) {
|
||||||
|
$settings = $c->get('settings')['db'];
|
||||||
|
$host = $settings['host'];
|
||||||
|
$name = $settings['name'];
|
||||||
|
$user = $settings['user'];
|
||||||
|
$pass = $settings['pass'];
|
||||||
|
$charset = $settings['charset'];
|
||||||
|
|
||||||
|
return new PDO("mysql:dbname=$name;host=$host;charset=$charset", $user, $pass);
|
||||||
|
};
|
||||||
|
|
||||||
|
$container['db'] = function ($c) {
|
||||||
|
$settings = $c->get('settings')['db'];
|
||||||
|
$pdo = $c->get('db.pdo');
|
||||||
|
return new NotORM($pdo);
|
||||||
|
};
|
||||||
|
|
||||||
// Inject the application main class
|
// Inject the application main class
|
||||||
/**
|
/**
|
||||||
* ==============
|
* ==============
|
||||||
|
@ -7,6 +7,15 @@ return [
|
|||||||
// Renderer settings
|
// Renderer settings
|
||||||
'renderer' => [
|
'renderer' => [
|
||||||
'template_path' => __DIR__ . '/../templates/',
|
'template_path' => __DIR__ . '/../templates/',
|
||||||
|
],
|
||||||
|
|
||||||
|
// Database settings
|
||||||
|
'db' => [
|
||||||
|
'host' => 'mysql.verictas.nl',
|
||||||
|
'user' => 'inforban_db',
|
||||||
|
'pass' => 'inforbank',
|
||||||
|
'name' => 'inforban_db',
|
||||||
|
'charset' => 'utf8'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user