File: 20locale.phpt

package info (click to toggle)
php-db 1.7.13-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 872 kB
  • ctags: 1,600
  • sloc: php: 6,913; pascal: 1,001; xml: 198; makefile: 55; sh: 24
file content (88 lines) | stat: -rw-r--r-- 1,930 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--TEST--
DB_driver::locale
--INI--
error_reporting = 2047
--SKIPIF--
<?phpi
chdir(dirname(__FILE__)); require_once './skipif.inc';
if (!function_exists('setlocale')) {
    die('skip setlocale is not defined');
}
if (!OS_UNIX) {
    die('skip not on a UNIX-like platform');
}
?>
--FILE--
<?php
require_once './mktable.inc';

if ($dbh->phptype == 'odbc') {
    if ($dbh->dbsyntax == 'odbc') {
        $type = $dbh->phptype;
    } else {
        $type = $dbh->dbsyntax;
    }
} else {
    $type = $dbh->phptype;
}

switch ($type) {
    case 'access':
        $decimal = 'SINGLE';
        break;
    case 'db2':
    case 'ibase':
        $decimal = 'DECIMAL(3,1)';
        break;
    case 'ifx':
        // doing this for ifx to keep certain versions happy
        $decimal = 'DECIMAL(3,1)';
        break;
    case 'msql':
        $decimal = 'REAL';
        break;
    case 'fbsql':
    case 'oci8':
        $decimal = 'DECIMAL(3,1)';
        break;
    default:
        $decimal = 'DECIMAL(3,1)';
}

$dbh->setErrorHandling(PEAR_ERROR_RETURN);
drop_table($dbh, 'localetest');

$res = $dbh->query("CREATE TABLE localetest (a $decimal)");
if (DB::isError($res)) {
    echo 'Unable to create table: '.$res->getMessage()."\n";
}

setlocale(LC_NUMERIC, 'de_DE');

$res = $dbh->query('INSERT INTO localetest (a) VALUES (?)', array(42.2));
if (DB::isError($res)) {
    echo 'Error inserting record: '.$res->getMessage()."\n";
    var_dump($res);
}

setlocale(LC_NUMERIC, 'en_AU');

$res = $dbh->query('INSERT INTO localetest (a) VALUES (?)', array(42.2));
if (DB::isError($res)) {
    echo 'Error inserting record: '.$res->getMessage()."\n";
    var_dump($res);
}

$res = $dbh->query('SELECT * FROM localetest');
if (DB::isError($res)) {
    echo 'Error retrieving count: '.$res->getMessage()."\n";
    var_dump($res);
} else {
    echo 'Got '.$res->numRows()." records.\n";
}

drop_table($dbh, 'localetest');

?>
--EXPECT--
Got 2 records.