Skip to content

Two connections to Postgres and MongoDB PHP 5.4 #38

Closed
@rbianchi

Description

@rbianchi

Hi Jens,

In our application (Laravel4) use two connections to Postgres databases and MongoDB.
Using PHP 5.3 we had no problems, but using PHP 5.4.9 have a problem with the instance of the connection to the DB you are getting 'jenssegers/mongodb/src/Jenssegers/Mongodb/Model.php'. I do not understand why it is that you are getting the connection to the Postgres database in 5.4 but work in 5.3.
We tested the PHP Mongo client 5.4 on a standalone application and it works.

The exception is:

       {"error""type":"ErrorException","message":"Argument 1 passed to Jenssegers\\Mongodb\\Builder::__construct() must be an instance of Jenssegers\\Mongodb\\Connection, instance of Illuminate\\Database\\PostgresConnection given, called in /vendor\/jenssegers\/mongodb\/src\/Jenssegers\/Mongodb\/Model.php on line 186 and defined","file":"/vendor\/jenssegers\/mongodb\/src\/Jenssegers\/Mongodb\/Builder.php","line":37}}

In my case I have defined:

Provider:

      'Jenssegers\Mongodb\MongodbServiceProvider'

Alias of the Laravel Eloquent Model:

      'Eloquent' => 'Illuminate\Database\Eloquent\Model',

Example of a Jenssegers model:

      use Jenssegers\Mongodb\Model as Eloquent;

      MongoData class extends Eloquent {
           protected $ collection = 'data';
      }

And finally,
The connections to the DB:

      'default' => 'pgsql'

      'mongodb' => array (
         'driver' => 'mongodb',
         'host' => 'localhost',
         'port' => 27017,
         'username' => 'user',
         'password' => 'password',
         'database' => 'database'
     )

     'pgsql' => array (
         'driver' => 'pgsql',
         'host' => 'localhost',
         'port' => 5432,
         'database' => 'database',
         'username' => 'user',
         'password' => 'password',
         'charset' => 'utf8',
         'prefix' =>'',
         'schema' => 'public',
     )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions