Commit 2a68db65 authored by Peter Göbel's avatar Peter Göbel

updated readme and examples

parent 474f9814
# PDO class for PHP
- See index.php for usage examples
- Change database connection credentials in class.database.php
\ No newline at end of file
- See [index.php](index.php) for usage examples
- Change database connection credentials in class.database.php
## Change database type
[PDO](http://php.net/manual/de/intro.pdo.php) works with a lot of database types: MySQL, SQLite, Postgres, ...
By default, [class.database.php](class.database.php) docks to MySQL, but you can replace it with whatever you like. A few examples:
### MySQL
protected static $dbConf = array(
"default" => array(
"type" => "mysql",
"config" => "host=localhost;dbname=XXX;port=XXX",
"user" => "XXX",
"password" => "XXX"
)
);
### SQLite
protected static $dbConf = array(
"default" => array(
"type" => "sqlite",
"config" => "qr.sqlite"
)
);
### Postgres
protected static $dbConf = array(
"default" => array(
"type" => "pgsql",
"config" => "host=localhost;dbname=XXX;port=XXX",
"user" => "XXX",
"password" => "XXX"
)
);
\ No newline at end of file
......@@ -12,7 +12,8 @@ class Database
"type" => "mysql",
"config" => "host=localhost;dbname=XXX;port=XXX",
"user" => "XXX",
"password" => "XXX")
"password" => "XXX"
)
);
protected $active = false;
......
<?php
// sample usage
// load dependencies
require_once('class.database.php');
require_once('class.example.php');
// init database object and connect to default server
$db = Database::get('default');
// init object for data handling
$obj = new Example($db);
// get data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment