Check for empty $schema in dml.psql.class.inc [message #7250] |
Wed, 06 February 2019 12:42 |
pdv
Messages: 15 Registered: January 2019
|
Junior Member |
|
|
Hi,
I'm new and trying to access some existing PostgreSQL databases with Radicore and on macos. Sofar I met a few problems which I could only solve by changing the code. I'll describe them in separate messages.
The first problem is similar to the one reported in the thread "SQLSRV Driver", message #4722. I could only connect to the database when hard coding the dbname (which is the postgresql schema).
The problem is in the following code in dml.pgsql.class.inc:
if (!empty($this->dbname) AND !empty($schema)) {
$result = $this->connect($schema) or trigger_error($this, E_USER_ERROR);
} else {
trigger_error('No value supplied for PGSQL_dbname', E_USER_ERROR);
} // if
This code fails because $schema is empty, e.g. when querying for the list of databases. $this->dbname refers here to the PGSQL_dbname. I removed the check on $schema.
The error message is also misleading in this case since PGSQL_dbname was not empty.
Regards,
Patrick
|
|
|
|
Re: Check for empty $schema in dml.psql.class.inc [message #7258 is a reply to message #7254] |
Thu, 07 February 2019 07:15 |
pdv
Messages: 15 Registered: January 2019
|
Junior Member |
|
|
Tony,
I realize the differences between MySQL and PostgreSQL, but it remains confusing.
I want to access existing postgresql-dbs and I had 2 options: install radicore in each of them in a separate schema, like this:
db1
---schema-radicore
------menu
------dict
....
---schema1
------table11
------table12
---....
db2
---schema-radicore
---.....
Or to install radicore in a separate pgsql-database, which I prefer:
db-radicore
---schema-public
------menu
------dict
....
db1
---schema1
------table11
------table12
...
db2
---schema2
------table21
------table22
---.....
This means I need at least 2 connections, one for a particular db and one for radicore.
This is my config.inc to access a pgsql-database bxtests with schema public (which I renamed to bxtests):
if (preg_match('/^(127.0.0.1|localhost|desktop|laptop)$/i', $_SERVER['SERVER_NAME'])) {
global $servers;
// server 0
$servers[0]['dbhost'] = 'localhost';
$servers[0]['dbengine'] = 'pgsql';
$servers[0]['dbusername'] = 'user1';
$servers[0]['dbuserpass'] = 'password1';
$servers[0]['dbport'] = '';
$servers[0]['dbsocket'] = '';
$servers[0]['dbprefix'] = '';
$servers[0]['dbnames'] = 'bxtests';
$servers[0]['PGSQL_dbname'] = 'bxtests';
$servers[0]['switch_dbnames'] = array('bxtests' => 'public'); // the PostgreSQL schema is 'public'
$servers[0]['ssl_key'] = '';
$servers[0]['ssl_cert'] = '';
$servers[0]['ssl_ca'] = '';
$servers[0]['ssl_capath'] = '';
$servers[0]['ssl_cipher'] = '';
// server 1
$servers[1]['dbhost'] = 'localhost';
$servers[1]['dbengine'] = 'pgsql';
$servers[1]['dbusername'] = 'user2';
$servers[1]['dbuserpass'] = 'password2';
$servers[1]['dbport'] = '';
$servers[1]['dbsocket'] = '';
$servers[1]['dbprefix'] = '';
$servers[1]['PGSQL_dbname'] = 'radicore';
$servers[1]['dbnames'] = '*';
} // if
With this server-configuration, when importing databases (schemas) I found that $schema was empty; I have not been able to clarify this, since I had not yet installed XDebug. I'll look at this again.
Regards,
Patrick
|
|
|
|
|
|
|
|
|
|
|
|