commit 8ad620461e810c25a1f4fd108078c20e194560ad
parent 24f6e43d0eed5ced9bbc0cea95950308a9a8fd2b
Author: Jan Dankert <devnull@localhost>
Date: Wed, 23 Nov 2011 23:36:21 +0100
Abfrage, ob Datenbank-Funktionen zur Verfügung stehen.
Diffstat:
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/db/postgresql.class.php b/db/postgresql.class.php
@@ -59,16 +59,22 @@ class DB_postgresql
else
$connect_function = 'pg_connect';
+ if ( ! function_exists($connect_function))
+ {
+ $this->error = 'Function does not exist: '.$connect_function.' Postgresql is not available';
+ return false;
+ }
+
if ( $pw != '' )
$this->connection = @$connect_function( "host=$host dbname=$db user=$user password=$pw" );
elseif ( $user != '' )
$this->connection = @$connect_function( "host=$host dbname=$db user=$user" );
elseif ( $host != '' )
$this->connection = @$connect_function( "host=$host dbname=$db" );
- else
+ else
$this->connection = @$connect_function( "dbname=$db");
- if ( ! is_resource($this->connection) )
+ if ( ! is_resource($this->connection) )
{
$this->error = 'Could not connect to postgresql-server '.$host.': '.@pg_errormessage();
return false;
diff --git a/db/sqlite.class.php b/db/sqlite.class.php
@@ -50,7 +50,13 @@ class DB_sqlite
$connect_function = 'sqlite_popen';
else
$connect_function = 'sqlite_open';
-
+
+ if ( ! function_exists($connect_function))
+ {
+ $this->error = 'Function does not exist: '.$connect_function.' SQlite is not available';
+ return false;
+ }
+
$this->connection = @$connect_function($filename,0666,$error);
if ( !is_resource($this->connection) )