Annotation of embedaddon/php/ext/interbase/tests/007.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: InterBase: array handling
        !             3: --SKIPIF--
        !             4: <?php include("skipif.inc"); ?>
        !             5: --FILE--
        !             6: <?php /* $Id: 007.phpt 160078 2004-05-30 16:20:25Z abies $ */
        !             7: 
        !             8:        require("interbase.inc");
        !             9:        
        !            10:        ibase_connect($test_base);
        !            11:        
        !            12:        ibase_query(
        !            13:                "create table test7 (
        !            14:                        iter            integer,
        !            15:                        v_multi         integer[10,10,10],
        !            16:                        v_char          char(100)[10],
        !            17:                        v_date      timestamp[10],
        !            18:                        v_decimal   decimal(18,3)[10],
        !            19:                        v_double        double precision[10],
        !            20:                        v_float     float[10],
        !            21:                        v_integer   integer[10],
        !            22:                        v_numeric   numeric(9,2)[10],
        !            23:                        v_smallint  smallint[10],
        !            24:                        v_varchar   varchar(1000)[10]
        !            25:                        )");
        !            26:        ibase_commit();
        !            27: 
        !            28:        /* if timefmt not supported, hide error */
        !            29:        ini_set('ibase.timestampformat',"%m/%d/%Y %H:%M:%S");
        !            30: 
        !            31:        echo "insert\n";
        !            32:        
        !            33:        for ($i = 1; $i <= 10; ++$i) {
        !            34:                for ($j = 1; $j <= 10; ++$j) {
        !            35:                        for ($k = 1; $k <= 10; ++$k) {
        !            36:                                $v_multi[$i][$j][$k] = $i * $j * $k;
        !            37:                        }
        !            38:                }
        !            39:        }
        !            40:                                
        !            41:        for($iter = 0; $iter < 3; $iter++) {
        !            42: 
        !            43:                /* prepare data  */
        !            44:                $v_char = array();
        !            45:                $v_date = array();
        !            46:                $v_decimal = array();
        !            47:                $v_double  = array();
        !            48:                $v_float = array();
        !            49:                $v_integer = array();
        !            50:                $v_numeric = array();
        !            51:                $v_smallint = array();
        !            52:                $v_varchar = array();
        !            53: 
        !            54:                for ($i = 1; $i <= 10; ++$i) {
        !            55:                        $v_char[$i] = rand_str(100);
        !            56:                        $v_date[$i] = rand_datetime();
        !            57:                        $v_decimal[$i] = rand_number(18,3);
        !            58:                        $v_double[$i]  = rand_number(20);
        !            59:                        $v_float[$i]   = rand_number(7);
        !            60:                        $v_integer[$i] = rand_number(9,0);
        !            61:                        $v_numeric[$i] = rand_number(9,2);
        !            62:                        $v_smallint[$i] = rand_number(5) % 32767;
        !            63:                        $v_varchar[$i] = rand_str(1000);
        !            64:                }
        !            65:                
        !            66:                ibase_query("insert into test7
        !            67:                        (iter,v_multi,v_char,v_date,v_decimal,v_double,v_float,
        !            68:                        v_integer,v_numeric,v_smallint,v_varchar)
        !            69:                        values (?,?,?,?,?,?,?,?,?,?,?)",
        !            70:                        $iter, $v_multi, $v_char, $v_date, $v_decimal, $v_double, $v_float,
        !            71:                        $v_integer, $v_numeric, $v_smallint, $v_varchar);
        !            72:                $sel = ibase_query("select * from test7 where iter = $iter");
        !            73: 
        !            74:                $row = ibase_fetch_object($sel,IBASE_FETCH_ARRAYS);
        !            75:                for ($i = 1; $i <= 10; ++$i) {
        !            76:                        
        !            77:                        if(strncmp($row->V_CHAR[$i],$v_char[$i],strlen($v_char[$i])) != 0) {
        !            78:                                echo " CHAR[$i] fail:\n";
        !            79:                                echo " in:  ".$v_char[$i]."\n";
        !            80:                                echo " out: ".$row->V_CHAR[$i]."\n";
        !            81:                        }
        !            82:                        if($row->V_DATE[$i] != $v_date[$i]) {
        !            83:                                echo " DATE[$i] fail\n";
        !            84:                                echo " in:  ".$v_date[$i]."\n";
        !            85:                                echo " out: ".$row->V_DATE[$i]."\n";
        !            86:                        }
        !            87:                        if($row->V_DECIMAL[$i] != $v_decimal[$i]) {
        !            88:                                echo " DECIMAL[$i] fail\n";
        !            89:                                echo " in:  ".$v_decimal[$i]."\n";
        !            90:                                echo " out: ".$row->V_DECIMAL[$i]."\n";
        !            91:                        }
        !            92:                        if(abs($row->V_DOUBLE[$i] - $v_double[$i]) > abs($v_double[$i] / 1E15)) {
        !            93:                                echo " DOUBLE[$i] fail\n";
        !            94:                                echo " in:  ".$v_double[$i]."\n";
        !            95:                                echo " out: ".$row->V_DOUBLE[$i]."\n";
        !            96:                        }
        !            97:                        if(abs($row->V_FLOAT[$i] - $v_float[$i]) > abs($v_float[$i] / 1E7)) {
        !            98:                                echo " FLOAT[$i] fail\n";
        !            99:                                echo " in:  ".$v_float[$i]."\n";
        !           100:                                echo " out: ".$row->V_FLOAT[$i]."\n";
        !           101:                        }
        !           102:                        if($row->V_INTEGER[$i] != $v_integer[$i]) {
        !           103:                                echo " INTEGER[$i] fail\n";
        !           104:                                echo " in:  ".$v_integer[$i]."\n";
        !           105:                                echo " out: ".$row->V_INTEGER[$i]."\n";
        !           106:                        }
        !           107:                        if ($row->V_NUMERIC[$i] != $v_numeric[$i]) {
        !           108:                                echo " NUMERIC[$i] fail\n";
        !           109:                                echo " in:  ".$v_numeric[$i]."\n";
        !           110:                                echo " out: ".$row->V_NUMERIC[$i]."\n";
        !           111:                        }
        !           112:                        if ($row->V_SMALLINT[$i] != $v_smallint[$i]) {
        !           113:                                echo " SMALLINT[$i] fail\n";
        !           114:                                echo " in:  ".$v_smallint[$i]."\n";
        !           115:                                echo " out: ".$row->V_SMALLINT[$i]."\n";
        !           116:                        }
        !           117:                        if ($row->V_VARCHAR[$i] != $v_varchar[$i]) {
        !           118:                                echo " VARCHAR[$i] fail:\n";
        !           119:                                echo " in:  ".$v_varchar[$i]."\n";
        !           120:                                echo " out: ".$row->V_VARCHAR[$i]."\n";
        !           121:                        }
        !           122:                }
        !           123:                ibase_free_result($sel);
        !           124:        }/* for($iter) */
        !           125: 
        !           126:        echo "select\n";
        !           127:        
        !           128:        $sel = ibase_query("SELECT v_multi[5,5,5],v_multi[10,10,10] FROM test7 WHERE iter = 0");
        !           129:        print_r(ibase_fetch_row($sel));
        !           130:        ibase_free_result($sel);
        !           131: 
        !           132:        for($iter = 1; $iter <= 3; $iter++) {
        !           133: 
        !           134:                if(!($sel = ibase_query(
        !           135:                        "select iter from test7 where v_char[$iter] LIKE ?", $v_char[$iter]."%")) ||
        !           136:                        !ibase_fetch_row($sel)) {
        !           137:                        echo "CHAR fail\n";
        !           138:                }
        !           139:                ibase_free_result($sel);
        !           140: 
        !           141:                if(!($sel = ibase_query(
        !           142:                        "select iter from test7 where v_date[$iter] = ?", $v_date[$iter])) ||
        !           143:                        !ibase_fetch_row($sel)) {
        !           144:                        echo "DATE fail\n";
        !           145:                }
        !           146:                ibase_free_result($sel);
        !           147:                if(!($sel = ibase_query(
        !           148:                        "select iter from test7 where v_decimal[$iter] = ?", $v_decimal[$iter])) ||
        !           149:                        !ibase_fetch_row($sel)) {
        !           150:                        echo "DECIMAL fail\n";
        !           151:                }
        !           152:                ibase_free_result($sel);
        !           153:                if(!($sel = ibase_query(
        !           154:                        "select iter from test7 where v_integer[$iter] = ?", $v_integer[$iter])) ||
        !           155:                        !ibase_fetch_row($sel)) {
        !           156:                        echo "INTEGER fail\n";
        !           157:                }
        !           158:                ibase_free_result($sel);
        !           159:                if(!($sel = ibase_query(
        !           160:                        "select iter from test7 where v_numeric[$iter] = ?", $v_numeric[$iter])) ||
        !           161:                        !ibase_fetch_row($sel)) {
        !           162:                        echo "NUMERIC fail\n";
        !           163:                }
        !           164:                ibase_free_result($sel);
        !           165:                if(!($sel = ibase_query(
        !           166:                        "select iter from test7 where v_smallint[$iter] = ?", $v_smallint[$iter])) ||
        !           167:                        !ibase_fetch_row($sel)) {
        !           168:                        echo "SMALLINT fail\n";
        !           169:                }
        !           170:                ibase_free_result($sel);
        !           171:        }
        !           172:        ibase_close();
        !           173:        echo "end of test\n";
        !           174: ?>
        !           175: --EXPECT--
        !           176: insert
        !           177: select
        !           178: Array
        !           179: (
        !           180:     [0] => 125
        !           181:     [1] => 1000
        !           182: )
        !           183: end of test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>