Welcome Guest, Not a member yet? Register   Sign In
building a dsn for use with CI
#1

(This post was last modified: 04-12-2020, 06:51 AM by richb201.)

I am trying to connect via a dsn to a remote database. I am confused as to how to build the dsn.

From php.net

<?php
$dsn 'mysql:host=localhost;dbname=testdb';
$username 'username';
$password 'password';
$options = array(
    
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
); 

$dbh = new PDO($dsn$username$password$options);
?>


from the CI manual pages:
$dsn = 'dbdriver://username:password@hostname/database';
$this->load->database($dsn);


I have connected to this databse via psql on the command line with:
psql --host=imagesdatabase.cwymdn16xxxes.us-east-1.rds.amazonaws.com --port=5432 --username=richb2 --password --dbname=postgres

How do I go from my working psql version above to the CI example? 

I tried this but I am getting a 500 error from the load database command below, which mean invalid driver
$dsn = 'jdbc:postgresql://imagesdatabase.cwymdn16xxxes.us-east-1.rds.amazonaws.com:5432/postgres -Urichb2';
$DB1 = $this->load->database($dsn, TRUE);
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB