Annotation of embedaddon/php/ext/sqlite3/tests/sqlite3_08_udf.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SQLite3::createFunction
! 3: --SKIPIF--
! 4: <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: function my_udf_md5($foo)
! 9: {
! 10: return md5($foo);
! 11: }
! 12:
! 13: require_once(dirname(__FILE__) . '/new_db.inc');
! 14: define('TIMENOW', time());
! 15:
! 16: echo "Creating Table\n";
! 17: var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)'));
! 18:
! 19: echo "INSERT into table\n";
! 20: var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')"));
! 21: var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')"));
! 22:
! 23: echo "CREATING UDF\n";
! 24: var_dump($db->createFunction('my_udf_md5', 'my_udf_md5'));
! 25:
! 26: echo "SELECTING results\n";
! 27: $results = $db->query("SELECT my_udf_md5(id) FROM test ORDER BY id ASC");
! 28: while ($result = $results->fetchArray(SQLITE3_NUM))
! 29: {
! 30: var_dump($result);
! 31: }
! 32: $results->finalize();
! 33:
! 34: echo "Closing database\n";
! 35: var_dump($db->close());
! 36: echo "Done\n";
! 37: ?>
! 38: --EXPECTF--
! 39: Creating Table
! 40: bool(true)
! 41: INSERT into table
! 42: bool(true)
! 43: bool(true)
! 44: CREATING UDF
! 45: bool(true)
! 46: SELECTING results
! 47: array(1) {
! 48: [0]=>
! 49: string(32) "0cc175b9c0f1b6a831c399e269772661"
! 50: }
! 51: array(1) {
! 52: [0]=>
! 53: string(32) "92eb5ffee6ae2fec3ad71c777531578f"
! 54: }
! 55: Closing database
! 56: bool(true)
! 57: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>