[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/DB/tests/driver/ -> 20locale.phpt (source)

   1  --TEST--
   2  DB_driver::locale
   3  --INI--
   4  error_reporting = 2047
   5  --SKIPIF--
   6  <?phpi
   7  chdir(dirname(__FILE__)); require_once  './skipif.inc';
   8  if (!function_exists('setlocale')) {
   9      die('skip setlocale is not defined');
  10  }
  11  if (!OS_UNIX) {
  12      die('skip not on a UNIX-like platform');
  13  }
  14  ?>
  15  --FILE--
  16  <?php
  17  require_once  './mktable.inc';
  18  
  19  if ($dbh->phptype == 'odbc') {
  20      if ($dbh->dbsyntax == 'odbc') {
  21          $type = $dbh->phptype;
  22      } else {
  23          $type = $dbh->dbsyntax;
  24      }
  25  } else {
  26      $type = $dbh->phptype;
  27  }
  28  
  29  switch ($type) {
  30      case 'access':
  31          $decimal = 'SINGLE';
  32          break;
  33      case 'db2':
  34      case 'ibase':
  35          $decimal = 'DECIMAL(3,1)';
  36          break;
  37      case 'ifx':
  38          // doing this for ifx to keep certain versions happy
  39          $decimal = 'DECIMAL(3,1)';
  40          break;
  41      case 'msql':
  42          $decimal = 'REAL';
  43          break;
  44      case 'fbsql':
  45      case 'oci8':
  46          $decimal = 'DECIMAL(3,1)';
  47          break;
  48      default:
  49          $decimal = 'DECIMAL(3,1)';
  50  }
  51  
  52  $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  53  drop_table($dbh, 'localetest');
  54  
  55  $res = $dbh->query("CREATE TABLE localetest (a $decimal)");
  56  if (DB::isError($res)) {
  57      echo 'Unable to create table: '.$res->getMessage()."\n";
  58  }
  59  
  60  setlocale(LC_NUMERIC, 'de_DE');
  61  
  62  $res = $dbh->query('INSERT INTO localetest (a) VALUES (?)', array(42.2));
  63  if (DB::isError($res)) {
  64      echo 'Error inserting record: '.$res->getMessage()."\n";
  65      var_dump($res);
  66  }
  67  
  68  setlocale(LC_NUMERIC, 'en_AU');
  69  
  70  $res = $dbh->query('INSERT INTO localetest (a) VALUES (?)', array(42.2));
  71  if (DB::isError($res)) {
  72      echo 'Error inserting record: '.$res->getMessage()."\n";
  73      var_dump($res);
  74  }
  75  
  76  $res = $dbh->query('SELECT * FROM localetest');
  77  if (DB::isError($res)) {
  78      echo 'Error retrieving count: '.$res->getMessage()."\n";
  79      var_dump($res);
  80  } else {
  81      echo 'Got '.$res->numRows()." records.\n";
  82  }
  83  
  84  drop_table($dbh, 'localetest');
  85  
  86  ?>
  87  --EXPECT--
  88  Got 2 records.


Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7