![]() |
connecting to postgresql with pg_pconnect() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: connecting to postgresql with pg_pconnect() (/showthread.php?tid=76023) Pages:
1
2
|
connecting to postgresql with pg_pconnect() - richb201 - 04-07-2020 I need to connect my app with a remote Postgresql database. My app is running on the web and each user has her own copy. Is there any functionality in Codeigniter to use postgresql? If I connect with pg_pconnect() do I do this once and have all the tasks share the handle or can each task do this and keep its own copy of the handle? RE: connecting to postgresql with pg_pconnect() - php_rocs - 04-07-2020 @richb201, What version of CI are you using? Assuming you are using CI 3.1.x here is the link ( https://codeigniter.com/userguide3/database/configuration.html?highlight=database#database-configuration ). RE: connecting to postgresql with pg_pconnect() - richb201 - 04-07-2020 Thanks php_rocs. I am using 3.1. I use this structure for a local copy of mySQL. Can I have more than one database connected? I am using postgres to hold images because Jaspersoft can use it and images can be really large in postrgres. I know it is not a good idea to keep the actual image in a bytea, but if i don't, I will have trouble with Jaspersoft server. So I can assume that I don't need to play with opening a connection and CI will do it for me? How about re-entrancy? Can I assume that is not a problem? RE: connecting to postgresql with pg_pconnect() - php_rocs - 04-08-2020 @richb201, Documentation for multiple database connections ( https://codeigniter.com/userguide3/database/connecting.html#connecting-to-multiple-databases ). RE: connecting to postgresql with pg_pconnect() - richb201 - 04-08-2020 thank you RE: connecting to postgresql with pg_pconnect() - richb201 - 04-10-2020 So now I want to add access to a remotely hosted copy of Postgres. But I don't want to redo the working mySQL functions. So I think I can create the $dsn to point at the Postgresql database: This is the string I use to connect to psql: psql --host=imagesdatabase.cwymdn16cxes.us-east-1.rds.amazonaws.com --port=5432 --username=richb201 --password --dbname=postgres Can I use $dsn2='--host=imagesdatabase.cwymdn16cxes.us-east-1.rds.amazonaws.com --port=5432 --username=richb201 --password=xyz --dbname=postgres' Or is there some other syntax that I need to use? And then to open it and assign the $DBPostgres=$this->load->database($dsn2, TRUE); And when I want to access the Postgres I will use $DBPostgres->query(); RE: connecting to postgresql with pg_pconnect() - richb201 - 05-30-2020 (04-08-2020, 10:17 AM)php_rocs Wrote: @richb201,I have two databases defined in my database.php. The first is called default and is my local mySQL database. The second is called postgres and connects to remote copy of postgresql. I then run this: $DB1 = $this->load->database('default', TRUE); $DB2 = $this->load->database('postgres', TRUE); $DB1 seems to work. $DB2 results in an error: "call to undefined function pg_connect()". The DSN for postgres is 'dsn' => 'jdbc:postgresql://imagesdatabase.cwymdn16cxes.us-east-1.rds.amazonaws.com:5432/postgres' This dsn works fine in another application I am using to connect to the postgresql database. Do I need to somehow load the postgres driver? BTW, my autoload.php contains: $autoload['drivers'] = array(); Does this means that IO have not loaded the pg driver? RE: connecting to postgresql with pg_pconnect() - php_rocs - 05-30-2020 @richb201, Is the other application on the same server as your current application? If not you might need to check your PHP.ini to make sure that the postgres plugin is turned on. RE: connecting to postgresql with pg_pconnect() - richb201 - 05-30-2020 hey Rocs! It is all running on my local PC at this time, except the RDS postgresql which is running on an AWS server somewhere. I am just not sure how to see the php.ini that is running inside the container. pg_connect() is not a CI function I am assuming. RE: connecting to postgresql with pg_pconnect() - php_rocs - 05-30-2020 @richb201, Yes, you are correct pg_connect() is not a CI function. Check the AWS forums or see if you can search the documentation. There has got to be a way for you to see your container's PHP.ini configuration. |