Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix 256 #257

Merged
merged 2 commits into from Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Persistence.php
Expand Up @@ -44,18 +44,20 @@ public static function connect($dsn, $user = null, $password = null, $args = [])
$password = $parts['pass'];
}

// Omitting UTF8 is always a bad problem, so unless it's specified we will do that to prevent nasty problems.
if (strpos($dsn, ';charset=') === false) {
$dsn .= ';charset=utf8';
}

if (strpos($dsn, ':') === false) {
throw new Exception(["Your DSN format is invalid. Must be in 'driver:host:options' format", 'dsn' => $dsn]);
}
$driver = explode(':', $dsn, 2)[0];

switch (strtolower(isset($args['driver']) ?: $driver)) {
case 'mysql':
// Omitting UTF8 is always a bad problem, so unless it's specified we will do that
// to prevent nasty problems. This is un-tested on other databases, so moving it here.
// It gives problem with sqlite
if (strpos($dsn, ';charset=') === false) {
$dsn .= ';charset=utf8';
}

case 'dumper':
case 'counter':
case 'sqlite':
Expand Down
2 changes: 1 addition & 1 deletion tests/smbo/lib/Account.php
Expand Up @@ -19,7 +19,7 @@ public function init()
/**
* create and return a trasnfer model.
*/
public function transfer(Account $a, $amount)
public function transfer(self $a, $amount)
{
$t = new Transfer($this->persistence, ['detached' => true]);
$t['account_id'] = $this->id;
Expand Down