Changeset 5236 for trunk/include
- Timestamp:
- Mar 21, 2010, 11:51:36 PM (14 years ago)
- Location:
- trunk/include
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/common.inc.php
r5235 r5236 105 105 106 106 // Database connection 107 $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'], 108 $conf['db_password'], $conf['db_base']); 109 pwg_select_db($conf['db_base'], $pwg_db_link); 107 try 108 { 109 $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'], 110 $conf['db_password'], $conf['db_base']); 111 } 112 catch (Exception $e) 113 { 114 my_error(l10n($e->getMessage(), true); 115 } 110 116 111 117 pwg_db_check_charset(); -
trunk/include/dblayer/functions_mysql.inc.php
r5230 r5236 33 33 */ 34 34 35 function pwg_db_connect($host, $user, $password, $database =null, $die=true)35 function pwg_db_connect($host, $user, $password, $database) 36 36 { 37 $link = @mysql_connect($host, $user, $password) or my_error('mysql_connect', $die); 38 39 return $link; 40 } 41 42 function pwg_select_db($database, $link, $die=true) 43 { 44 return @mysql_select_db($database, $link) or my_error('mysql_select_db', $die); 37 $link = @mysql_connect($host, $user, $password); 38 if (!$link) 39 { 40 throw new Exception("Can't connect to server"); 41 } 42 if (mysql_select_db($database, $link)) 43 { 44 return $link; 45 } 46 else 47 { 48 throw new Exception('Connection to server succeed, but it was impossible to connect to database'); 49 } 45 50 } 46 51 -
trunk/include/dblayer/functions_pdo-sqlite.inc.php
r5230 r5236 34 34 */ 35 35 36 function pwg_db_connect($host, $user, $password, $database , $die=true)36 function pwg_db_connect($host, $user, $password, $database) 37 37 { 38 38 global $conf; … … 40 40 $db_file = sprintf('sqlite:%s/%s.db', $conf['local_data_dir'], $database); 41 41 42 try {43 $link = new PDO($db_file);44 } catch (Exception $e){45 my_error('sqlite::open', $die);42 $link = new PDO($db_file); 43 if (!$link) 44 { 45 throw new Exception('Connection to server succeed, but it was impossible to connect to database'); 46 46 } 47 47 … … 55 55 56 56 return $link; 57 }58 59 function pwg_select_db($database=null, $link=null, $die=null)60 {61 return true;62 57 } 63 58 -
trunk/include/dblayer/functions_pgsql.inc.php
r5230 r5236 34 34 */ 35 35 36 function pwg_db_connect($host, $user, $password, $database , $die=true)36 function pwg_db_connect($host, $user, $password, $database) 37 37 { 38 38 $connection_string = ''; … … 50 50 $password, 51 51 $database); 52 $link = pg_connect($connection_string) or my_error('pg_connect', $die); 53 54 return $link; 52 $link = pg_connect($connection_string); 53 if (!$link) 54 { 55 throw new Exception("Can't connect to server"); 56 } 57 else 58 { 59 return $link; 60 } 55 61 } 56 62 -
trunk/include/dblayer/functions_sqlite.inc.php
r5230 r5236 34 34 */ 35 35 36 function pwg_db_connect($host, $user, $password, $database , $die=true)36 function pwg_db_connect($host, $user, $password, $database) 37 37 { 38 38 global $conf; … … 48 48 $sqlite_open_mode = SQLITE3_OPEN_READWRITE; 49 49 } 50 try { 51 $link = new SQLite3($db_file, $sqlite_open_mode); 52 } catch (Exception $e) { 53 my_error('sqlite::open', $die); 50 51 $link = new SQLite3($db_file, $sqlite_open_mode); 52 if (!$link) 53 { 54 throw new Exception('Connection to server succeed, but it was impossible to connect to database'); 54 55 } 55 56 … … 63 64 64 65 return $link; 65 }66 67 function pwg_select_db($database=null, $link=null, $die=null)68 {69 return true;70 66 } 71 67
Note: See TracChangeset
for help on using the changeset viewer.