Annotation of embedaddon/php/ext/mysqli/tests/020.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mysqli bind_param/bind_result date
                      3: --SKIPIF--
                      4: <?php
                      5: require_once('skipif.inc');
                      6: require_once('skipifconnectfailure.inc');
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10:        require_once("connect.inc");
                     11: 
                     12:        /*** test mysqli_connect 127.0.0.1 ***/
                     13:        $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
                     14: 
                     15:        mysqli_select_db($link, $db);
                     16:        mysqli_query($link, "SET sql_mode=''");
                     17: 
                     18:        mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
                     19: 
                     20:        $rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
                     21:                c1 date,
                     22:                c2 time,
                     23:                c3 timestamp(14),
                     24:                c4 year,
                     25:                c5 datetime,
                     26:                c6 timestamp(4),
                     27:                c7 timestamp(6))");
                     28: 
                     29:        if (!$rc)
                     30:                $rc = mysqli_query($link,"CREATE TABLE test_bind_result(
                     31:                c1 date,
                     32:                c2 time,
                     33:                c3 timestamp,
                     34:                c4 year,
                     35:                c5 datetime,
                     36:                c6 timestamp,
                     37:                c7 timestamp)");
                     38: 
                     39:        $stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
                     40:        mysqli_stmt_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
                     41: 
                     42:        $d1 = "2002-01-02";
                     43:        $d2 = "12:49:00";
                     44:        $d3 = "2002-01-02 17:46:59";
                     45:        $d4 = "2010";
                     46:        $d5 = "2010-07-10";
                     47:        $d6 = "2020";
                     48:        $d7 = "1999-12-29";
                     49: 
                     50:        mysqli_stmt_execute($stmt);
                     51:        mysqli_stmt_close($stmt);
                     52: 
                     53:        $stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
                     54: 
                     55:        mysqli_stmt_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
                     56: 
                     57:        mysqli_stmt_execute($stmt);
                     58:        mysqli_stmt_fetch($stmt);
                     59: 
                     60:        $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
                     61: 
                     62:        var_dump($test);
                     63: 
                     64:        mysqli_stmt_close($stmt);
                     65:        mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
                     66:        mysqli_close($link);
                     67: 
                     68:        print "done!";
                     69: ?>
                     70: --CLEAN--
                     71: <?php
                     72: require_once("connect.inc");
                     73: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                     74:    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                     75: 
                     76: if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
                     77:        printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     78: 
                     79: mysqli_close($link);
                     80: ?>
                     81: --EXPECTF--
                     82: array(7) {
                     83:   [0]=>
                     84:   %s(10) "2002-01-02"
                     85:   [1]=>
                     86:   %s(8) "12:49:00"
                     87:   [2]=>
                     88:   %s(19) "2002-01-02 17:46:59"
                     89:   [3]=>
                     90:   int(2010)
                     91:   [4]=>
                     92:   %s(19) "2010-07-10 00:00:00"
                     93:   [5]=>
                     94:   %s(19) "0000-00-00 00:00:00"
                     95:   [6]=>
                     96:   %s(19) "1999-12-29 00:00:00"
                     97: }
                     98: done!

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