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

1.1       misho       1: --TEST--
                      2: sqlite: regular functions with closures
                      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:        array("one", "uno"),
                     14:        array("two", "dos"),
                     15:        array("three", "tres"),
                     16:        );
                     17: 
                     18: sqlite_query("CREATE TABLE strings(a,b)", $db);
                     19: 
                     20: foreach ($data as $row) {
                     21:        sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
                     22: }
                     23: 
                     24: sqlite_create_function($db, "implode", function () {
                     25:        $args = func_get_args();
                     26:        $sep = array_shift($args);
                     27:        return implode($sep, $args);
                     28: });
                     29: 
                     30: $r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
                     31: while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
                     32:        var_dump($row);
                     33: }
                     34: 
                     35: sqlite_close($db);
                     36: 
                     37: echo "DONE!\n";
                     38: ?>
                     39: --EXPECT--
                     40: array(1) {
                     41:   [0]=>
                     42:   string(7) "one-uno"
                     43: }
                     44: array(1) {
                     45:   [0]=>
                     46:   string(7) "two-dos"
                     47: }
                     48: array(1) {
                     49:   [0]=>
                     50:   string(10) "three-tres"
                     51: }
                     52: DONE!

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