diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/sqlite3/tests/sqlite3_36_create_collation.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/sqlite3/tests/sqlite3_36_create_collation.phpt')
-rw-r--r-- | ext/sqlite3/tests/sqlite3_36_create_collation.phpt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ext/sqlite3/tests/sqlite3_36_create_collation.phpt b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt new file mode 100644 index 0000000..c4d88c6 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE sequence +--SKIPIF-- +<?php require_once dirname(__FILE__) . '/skipif.inc'; ?> +--FILE-- +<?php + +require_once dirname(__FILE__) . '/new_db.inc'; + +$db->createCollation('NAT', 'strnatcmp'); + +$db->exec('CREATE TABLE t (s varchar(4))'); + +$stmt = $db->prepare('INSERT INTO t VALUES (?)'); +foreach(array('a1', 'a10', 'a2') as $s){ + $stmt->bindParam(1, $s); + $stmt->execute(); +} + +$defaultSort = $db->query('SELECT s FROM t ORDER BY s'); //memcmp() sort +$naturalSort = $db->query('SELECT s FROM t ORDER BY s COLLATE NAT'); //strnatcmp() sort + +echo "default\n"; +while ($row = $defaultSort->fetchArray()){ + echo $row['s'], "\n"; +} + +echo "natural\n"; +while ($row = $naturalSort->fetchArray()){ + echo $row['s'], "\n"; +} + +$db->close(); + +?> +--EXPECT-- +default +a1 +a10 +a2 +natural +a1 +a2 +a10 |