Annotation of embedaddon/php/ext/sqlite/tests/sqlite_022.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: sqlite: sqlite_seek
                      3: --INI--
                      4: sqlite.assoc_case=0
                      5: --SKIPIF--
                      6: <?php # vim:ft=php
                      7: if (!extension_loaded("sqlite")) print "skip"; ?>
                      8: --FILE--
                      9: <?php 
                     10: include "blankdb.inc";
                     11: 
                     12: $data = array(
                     13:        "one",
                     14:        "two",
                     15:        "three"
                     16:        );
                     17: 
                     18: sqlite_query("CREATE TABLE strings(a)", $db);
                     19: 
                     20: foreach ($data as $str) {
                     21:        sqlite_query("INSERT INTO strings VALUES('$str')", $db);
                     22: }
                     23: 
                     24: $res = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM);
                     25: for ($idx = -1; $idx < 4; $idx++) {
                     26:        echo "====SEEK:$idx====\n";
                     27:        sqlite_seek($res, $idx);
                     28:        var_dump(sqlite_current($res));
                     29: }
                     30: echo "====AGAIN====\n";
                     31: for ($idx = -1; $idx < 4; $idx++) {
                     32:        echo "====SEEK:$idx====\n";
                     33:        sqlite_seek($res, $idx);
                     34:        var_dump(sqlite_current($res));
                     35: }
                     36: 
                     37: sqlite_close($db);
                     38: 
                     39: echo "====DONE!====\n";
                     40: ?>
                     41: --EXPECTF--
                     42: ====SEEK:-1====
                     43: 
                     44: Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
                     45: array(1) {
                     46:   [0]=>
                     47:   string(3) "one"
                     48: }
                     49: ====SEEK:0====
                     50: array(1) {
                     51:   [0]=>
                     52:   string(3) "one"
                     53: }
                     54: ====SEEK:1====
                     55: array(1) {
                     56:   [0]=>
                     57:   string(3) "two"
                     58: }
                     59: ====SEEK:2====
                     60: array(1) {
                     61:   [0]=>
                     62:   string(5) "three"
                     63: }
                     64: ====SEEK:3====
                     65: 
                     66: Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
                     67: array(1) {
                     68:   [0]=>
                     69:   string(5) "three"
                     70: }
                     71: ====AGAIN====
                     72: ====SEEK:-1====
                     73: 
                     74: Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
                     75: array(1) {
                     76:   [0]=>
                     77:   string(5) "three"
                     78: }
                     79: ====SEEK:0====
                     80: array(1) {
                     81:   [0]=>
                     82:   string(3) "one"
                     83: }
                     84: ====SEEK:1====
                     85: array(1) {
                     86:   [0]=>
                     87:   string(3) "two"
                     88: }
                     89: ====SEEK:2====
                     90: array(1) {
                     91:   [0]=>
                     92:   string(5) "three"
                     93: }
                     94: ====SEEK:3====
                     95: 
                     96: Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
                     97: array(1) {
                     98:   [0]=>
                     99:   string(5) "three"
                    100: }
                    101: ====DONE!====

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