Skip to content

Commit

Permalink
Updating installer to use the new Capsule interface
Browse files Browse the repository at this point in the history
The Pyro core does this but the syntax for the installer was out of
date.
  • Loading branch information
adamfairholm committed Jun 3, 2013
1 parent 043336b commit 7b7d929
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions installer/libraries/Installer_lib.php
@@ -1,6 +1,6 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

use Illuminate\Database\Capsule;
use Illuminate\Database\Capsule\Manager as Capsule;

/**
* @author PyroCMS Dev Team
Expand Down Expand Up @@ -207,16 +207,23 @@ public function install(array $user, array $db)
break;
}

$capsule = new Capsule(array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'default',
'connections' => array(
'default' => $config,
),
$capsule = new Capsule;

$capsule->addConnection(array(
'driver' => $config['driver'],
'host' => $config['host'],
'database' => $config['database'],
'username' => $config['username'],
'prefix' => $config['prefix'],
'password' => $config['password'],
'charset' => $config['charset'],
'collation' => $config['collation'],
));

$capsule->bootEloquent();

$capsule->setAsGlobal();

// Connect using the Laravel Database component
$conn = $capsule->connection();

Expand Down

2 comments on commit 7b7d929

@huglester
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it works... but does the:

$image = DB::table('photos')
            ->where('image', $filename)
            ->first();

should work?

@sshussain270
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an application using exactly the same code but addConnection doesnt work, this is where my script stops. I have added it as a question here: http://stackoverflow.com/questions/36967860/illuminate-library-capsule-object-not-accepting-addconnection-command

Please sign in to comment.