Changeset 6090


Ignore:
Timestamp:
May 7, 2010, 2:34:56 AM (10 years ago)
Author:
plg
Message:

bug 1648 fixed: add the pwg_db_check_version functions for pdo-sqlite, sqlite
and pgsql, also make the $pwg_db_link global in the install_db_connect function
so that it can be used in SQLite functions.

bug fixed: with pdo-sqlite, pwg_db_num_rows always returns 0, so when
initializing user data, it tries to insert the same row twice.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_install.inc.php

    r5982 r6090  
    144144function install_db_connect(&$infos, &$errors)
    145145{
     146  global $pwg_db_link;
     147 
    146148  try
    147149  {
  • trunk/include/dblayer/functions_pdo-sqlite.inc.php

    r5503 r6090  
    2222// +-----------------------------------------------------------------------+
    2323
    24 define('REQUIRED_PDO-SQLITE_VERSION', '3.0.0');
     24define('REQUIRED_PDO_SQLITE_VERSION', '3.0.0');
    2525define('DB_ENGINE', 'SQLite');
    2626
     
    5454
    5555  return $link;
     56}
     57
     58function pwg_db_check_version()
     59{
     60  $current_version = pwg_get_db_version();
     61  if (version_compare($current_version, REQUIRED_PDO_SQLITE_VERSION, '<'))
     62  {
     63    fatal_error(
     64      sprintf(
     65        'your database version is too old, you have "%s" and you need at least "%s"',
     66        $current_version,
     67        REQUIRED_PDO_SQLITE_VERSION
     68        )
     69      );
     70  }
    5671}
    5772
  • trunk/include/dblayer/functions_pgsql.inc.php

    r5267 r6090  
    5858  {
    5959    return $link;
     60  }
     61}
     62
     63function pwg_db_check_version()
     64{
     65  $current_version = pwg_get_db_version();
     66  if (version_compare($current_version, REQUIRED_PGSQL_VERSION, '<'))
     67  {
     68    fatal_error(
     69      sprintf(
     70        'your database version is too old, you have "%s" and you need at least "%s"',
     71        $current_version,
     72        REQUIRED_PGSQL_VERSION
     73        )
     74      );
    6075  }
    6176}
  • trunk/include/dblayer/functions_sqlite.inc.php

    r5503 r6090  
    6565}
    6666
     67function pwg_db_check_version()
     68{
     69  $current_version = pwg_get_db_version();
     70  if (version_compare($current_version, REQUIRED_SQLITE_VERSION, '<'))
     71  {
     72    fatal_error(
     73      sprintf(
     74        'your database version is too old, you have "%s" and you need at least "%s"',
     75        $current_version,
     76        REQUIRED_SQLITE_VERSION
     77        )
     78      );
     79  }
     80}
     81
    6782function pwg_db_check_charset()
    6883{
  • trunk/include/functions_user.inc.php

    r5982 r6090  
    299299  WHERE ui.user_id = \''.$user_id.'\'';
    300300    $result = pwg_query($query);
    301     if (pwg_db_num_rows($result) > 0)
     301    if ($result)
    302302    {
    303303      break;
Note: See TracChangeset for help on using the changeset viewer.