-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jukka Svahn
committed
May 14, 2013
1 parent
bd3b315
commit 650e031
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Examples; | ||
use Rah\Danpu\Dump; | ||
use Rah\Danpu\Config; | ||
use Rah\Danpu\Export; | ||
use Rah\Danpu\Import; | ||
|
||
// Include Composer's autoloader. You can also use | ||
// any other PSR-0 compatible autoloader. Just point | ||
// the autoloader to the '../src' directory with the | ||
// namespace of Rah\Danpu. | ||
|
||
include '../vendor/autoload.php'; | ||
|
||
// Creates a new instance of Rah\Danpu\Dump. | ||
|
||
$dump = new Dump; | ||
$dump | ||
->file(__DIR__ . '/file.sql') | ||
->dsn('mysql:dbname=database;host=localhost') | ||
->user('username') | ||
->pass('password') | ||
->tmp('/tmp'); | ||
|
||
// Exports the database. | ||
|
||
new Export($dump); | ||
|
||
// Imports the database. | ||
|
||
new Import($dump); | ||
|
||
// Alternatively you could create a personalized config instance | ||
// by extending. | ||
|
||
class MyAppConfig extends Config | ||
{ | ||
public $file = 'file.sql'; | ||
public $dsn = 'mysql:dbname=database;host=localhost'; | ||
public $user = 'username'; | ||
public $pass = 'password'; | ||
public $tmp = '/tmp'; | ||
} | ||
|
||
// Export again using MyAppConfig. | ||
|
||
new Export(new MyAppConfig); | ||
|
||
// Or import. | ||
|
||
new Import(new MyAppConfig); |