[pLog-svn] r6451 - plog/trunk/class/database

Mark Wu markplace at gmail.com
Sun May 25 23:20:54 EDT 2008


Hi Jon:

I try this n in my local development machine, I get

" Header already  send" error message everywhere.

So, I revert it first to get the further developemet can go on.

BTW, I think we just need to show the error messages from DB here, why you
want to capture the whole error?? Any ideas?

Mark

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net 
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of 
> jondaley at devel.lifetype.net
> Sent: Friday, May 09, 2008 10:38 PM
> To: plog-svn at devel.lifetype.net
> Subject: [pLog-svn] r6451 - plog/trunk/class/database
> 
> Author: jondaley
> Date: 2008-05-09 10:38:01 -0400 (Fri, 09 May 2008) New Revision: 6451
> 
> Modified:
>    plog/trunk/class/database/ltdb.class.php
> Log:
> use output buffering to catch php library errors (we can use 
> this method to catch lots of issues, like plugins/locales/etc 
> that have extra spaces/newlines/etc in them).  auto retry for 
> hosts that don't allow non-persistent connections.  remove 
> die() since we have exceptions
> 
> Modified: plog/trunk/class/database/ltdb.class.php
> ===================================================================
> --- plog/trunk/class/database/ltdb.class.php	2008-05-09 
> 14:12:33 UTC (rev 6450)
> +++ plog/trunk/class/database/ltdb.class.php	2008-05-09 
> 14:38:01 UTC (rev 6451)
> @@ -76,20 +76,26 @@
>                  $dbcharset = $fileConfig->getValue( 
> "db_character_set", DEFAULT_DATABASE_CHARSET );
>                  $dbpersistent   = $fileConfig->getValue( 
> "db_persistent" );
>                  if($dbpersistent == true) {
> +                    ob_start();
>  	            	if( !$db->PConnect( $host, $username, 
> $password, $dbname, $dbcharset )) {
> -	            	    $message = "Fatal error: could not 
> connect to the database!".
> -	            	               " Error: ".$db->ErrorMsg();
> -	            		throw( new Exception( $message ));
> -	            		die();
> -	            	}
> +                            // some hosts don't allow 
> persistent connections, just retry
> +                            // with a regular connect, and 
> avoid an error message
> +                        if( !$db->Connect( $host, $username, 
> $password, $dbname, $dbcharset )) {
> +                            $message = "Fatal error: could 
> not connect to the database!".
> +                                " Error: 
> ".$db->ErrorMsg().ob_get_clean();
> +                            throw( new Exception( $message ));
> +                        }
> +                    }
> +                    ob_end_flush();
>              	}
>              	else {
> +                    ob_start();
>  	            	if( !$db->Connect( $host, $username, 
> $password, $dbname, $dbcharset )) {
>  	            	    $message = "Fatal error: could not 
> connect to the database!".
> -	            	               " Error: ".$db->ErrorMsg();
> +	            	               " Error: 
> ".$db->ErrorMsg().ob_get_clean();
>  	            		throw( new Exception( $message ));
> -	            		die();
>  	            	}
> +                    ob_end_flush();
>              	}
>  
>  				// pass the options to the 
> driver, if any
> 
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list