Use postgres DB for package

Permalink
Hi,

I want to connect a package which is able to add and list some events (meaning dates) to a postgres database.
My setup:
I have a MAMPstack from bitnami extended by the postgres-module. I installed the newest (5.7.5.4) concrete5 version and everything is fine. I can use the package with MySQL without any issues, but I want to save the data from this package on postgres.
So here is what I have within the
application/config/database.php:
<?php
return array(
    'default-connection' => 'concrete',
    'drivers' => array(
        'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver'
    ),
    'connections' => array(
        'concrete' => array(
            'driver' => 'c5_pdo_mysql',
            'server' => 'localhost',
            'database' => 'concrete5',
            'username' => 'username',
            'password' => 'password',
            'charset' => 'utf8',
        ),

But now I don't know where to add the stuff with the connection. I already red the article about "Advanced: Using dependency injection" here:http://documentation.concrete5.org/developers/database-management/a...
But still have no idea.
My package controller looks like this:
<?php
namespace Concrete\Package\CookbookEvents;
use Concrete\Core\Database\Connection\Connection;
use Package;
use BlockType;
use SinglePage;
defined('C5_EXECUTE') or die(_("Access Denied."));
class Controller extends Package
{
    protected $pkgHandle = 'cookbook_events';
    protected $appVersionRequired = '5.7.4.0';
    protected $pkgVersion = '1.0.0';
    protected $connection;
    public function __construct()
    {


And I tried to add a constructor with the connection stuff mentioned in the article above, but everytime I install the package the table is created within the mysql database and not within postgres.

Same problem if I try to add the connection stuff within a constructor in my Model which looks like this:
<?php
namespace Concrete\Package\CookbookEvents\Src;
use \Concrete\Core\Legacy\Model;
defined('C5_EXECUTE') or die(_("Access Denied."));
class CookbookEvent extends Model
{
    protected $_table = 'CookbookEvents';
    public function getDate()
    {
        return utf8_encode(strftime('%d. %b %Y', strtotime($this->event_date)));
    }
    public function getTitle()
    {
        return $this->title;
    }


Where is my mistake or misunderstanding?

Thanks for your help in advance.

Best, Michael

MichaB
 

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.