Changeset 5230


Ignore:
Timestamp:
03/21/10 22:15:54 (10 years ago)
Author:
patdenice
Message:

feature 1255: add pwg_select_db function.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/common.inc.php

    r5215 r5230  
    106106// Database connection 
    107107$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'], 
    108                               $conf['db_password'], $conf['db_base']) 
    109   or my_error('pwg_db_connect', true); 
     108                              $conf['db_password'], $conf['db_base']); 
     109pwg_select_db($conf['db_base'], $pwg_db_link); 
    110110 
    111111pwg_db_check_charset(); 
  • trunk/include/dblayer/functions_mysql.inc.php

    r5196 r5230  
    3333 */ 
    3434 
    35 function pwg_db_connect($host, $user, $password, $database) 
     35function pwg_db_connect($host, $user, $password, $database=null, $die=true) 
    3636 
    37   $link = mysql_connect($host, $user, $password) or my_error('mysql_connect', false); 
    38   mysql_select_db($database, $link) or my_error('mysql_select_db', false); 
     37  $link = @mysql_connect($host, $user, $password) or my_error('mysql_connect', $die); 
    3938 
    4039  return $link; 
     40} 
     41 
     42function pwg_select_db($database, $link, $die=true) 
     43{ 
     44  return @mysql_select_db($database, $link) or my_error('mysql_select_db', $die); 
    4145} 
    4246 
  • trunk/include/dblayer/functions_pdo-sqlite.inc.php

    r5196 r5230  
    3434 */ 
    3535 
    36 function pwg_db_connect($host, $user, $password, $database) 
     36function pwg_db_connect($host, $user, $password, $database, $die=true) 
    3737{ 
    3838  global $conf; 
     
    4343    $link = new PDO($db_file); 
    4444  } catch (Exception $e) { 
    45     my_error('sqlite::open', true); 
     45    my_error('sqlite::open', $die); 
    4646  } 
    4747 
     
    5555 
    5656  return $link; 
     57} 
     58 
     59function pwg_select_db($database=null, $link=null, $die=null) 
     60{ 
     61  return true; 
    5762} 
    5863 
  • trunk/include/dblayer/functions_pgsql.inc.php

    r5196 r5230  
    3434 */ 
    3535 
    36 function pwg_db_connect($host, $user, $password, $database) 
     36function pwg_db_connect($host, $user, $password, $database, $die=true) 
    3737{ 
    3838  $connection_string = ''; 
     
    5050                                $password, 
    5151                                $database); 
    52   $link = pg_connect($connection_string) or my_error('pg_connect', false);   
     52  $link = pg_connect($connection_string) or my_error('pg_connect', $die);   
    5353 
    5454  return $link; 
     55} 
     56 
     57function pwg_select_db($database=null, $link=null, $die=null) 
     58{ 
     59  return true; 
    5560} 
    5661 
  • trunk/include/dblayer/functions_sqlite.inc.php

    r5196 r5230  
    3434 */ 
    3535 
    36 function pwg_db_connect($host, $user, $password, $database) 
     36function pwg_db_connect($host, $user, $password, $database, $die=true) 
    3737{ 
    3838  global $conf; 
     
    5151    $link = new SQLite3($db_file, $sqlite_open_mode); 
    5252  } catch (Exception $e) { 
    53     my_error('sqlite::open', true); 
     53    my_error('sqlite::open', $die); 
    5454  } 
    5555 
     
    6363 
    6464  return $link; 
     65} 
     66 
     67function pwg_select_db($database=null, $link=null, $die=null) 
     68{ 
     69  return true; 
    6570} 
    6671 
  • trunk/install.php

    r5220 r5230  
    228228if ( isset( $_POST['install'] )) 
    229229{ 
     230  ob_start(); 
    230231  if (($pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'],  
    231                                      $_POST['dbpasswd'], $_POST['dbname']))!==false)  
    232   { 
    233  
    234     array_push( $infos, l10n('Parameters are correct') ); 
     232                                     $_POST['dbpasswd'], $_POST['dbname'], false))!==false)  
     233  { 
     234    if (pwg_select_db($_POST['dbname'], $pwg_db_link, false)!==false) 
     235    { 
     236      array_push( $infos, l10n('Parameters are correct') ); 
     237    } 
     238    else 
     239    { 
     240      array_push( $errors, 
     241        l10n('Connection to server succeed, but it was impossible to connect to database') ); 
     242    } 
     243    ob_end_clean(); 
    235244 
    236245    $required_version = constant('REQUIRED_'.strtoupper($dblayer).'_VERSION'); 
     
    262271  { 
    263272    array_push( $errors, l10n('Can\'t connect to server') ); 
    264   } 
    265  
     273    ob_end_clean(); 
     274  } 
    266275  $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); 
    267276  if ( empty($webmaster)) 
  • trunk/upgrade.php

    r5215 r5230  
    5353// Database connection 
    5454$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],  
    55                               $conf['db_password'], $conf['db_base'])  
    56   or my_error('pwg_db_connect', true); 
     55                              $conf['db_password'], $conf['db_base']); 
     56pwg_select_db($conf['db_base'], $pwg_db_link); 
    5757 
    5858pwg_db_check_charset(); 
  • trunk/upgrade_feed.php

    r5215 r5230  
    5757 
    5858$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],  
    59                               $conf['db_password'], $conf['db_base'])  
    60   or my_error('pwg_db_connect', true); 
     59                              $conf['db_password'], $conf['db_base']); 
     60pwg_select_db($conf['db_base'], $pwg_db_link); 
    6161 
    6262pwg_db_check_charset(); 
Note: See TracChangeset for help on using the changeset viewer.