[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3154] trunk/LedgerSMB/Initiate.pm



Revision: 3154
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3154&view=rev
Author:   einhverfr
Date:     2011-05-22 19:48:18 +0000 (Sun, 22 May 2011)

Log Message:
-----------
Committing Ian Goodacre's Patch to Initiate.pm

Modified Paths:
--------------
    trunk/LedgerSMB/Initiate.pm

Modified: trunk/LedgerSMB/Initiate.pm
===================================================================
--- trunk/LedgerSMB/Initiate.pm	2011-05-22 19:44:31 UTC (rev 3153)
+++ trunk/LedgerSMB/Initiate.pm	2011-05-22 19:48:18 UTC (rev 3154)
@@ -210,15 +210,17 @@
 
     if ( !$form->{edit} ) {
 
-	$form->{initiateon}=0;	
+        # If we can connect to the database, then it already exists
+        my $tempdbh = DBI->connect(
+            "dbi:Pg:db=$form->{database};host=$form->{dbhost};port=$form->{dbport}",
+            $form->{username},
+            $form->{password},
+            { PrintError => 0 },
+        );
 
-        $tempdbh = LedgerSMB::Initiate->getdbh($form);
 
-	$form->{initiateon}=1;	
-
- 	$form->{tempdbh}=$tempdbh;        
-
-	if ( lc($tempdbh) ne "no999" ) {
+        if ( defined($tempdbh)) {
+            $tempdbh->disconnect;
             $form->error( __FILE__ . ':' . __LINE__ . ': '
                   . $locale->text( '[_1] is already a database!', $form->{database} )
             );


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.