Catch exceptions in PDO constructor
This commit is contained in:
		
					parent
					
						
							
								93fb98959a
							
						
					
				
			
			
				commit
				
					
						37262c24d9
					
				
			
		
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -75,9 +75,11 @@ class dba {
 | 
			
		|||
			if (isset($a->config["system"]["db_charset"])) {
 | 
			
		||||
				$connect .= ";charset=".$a->config["system"]["db_charset"];
 | 
			
		||||
			}
 | 
			
		||||
			$this->db = @new PDO($connect, $user, $pass);
 | 
			
		||||
			if (!$this->db->errorCode()) {
 | 
			
		||||
			try {
 | 
			
		||||
				$this->db = @new PDO($connect, $user, $pass);
 | 
			
		||||
				$this->connected = true;
 | 
			
		||||
			} catch (PDOException $e) {
 | 
			
		||||
				$this->connected = false;
 | 
			
		||||
			}
 | 
			
		||||
		} elseif (class_exists('mysqli')) {
 | 
			
		||||
			$this->driver = 'mysqli';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue