Annotation of embedaddon/php/ext/sqlite3/tests/sqlite3_36_create_collation.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE sequence
                      3: --SKIPIF--
                      4: <?php require_once dirname(__FILE__) .  '/skipif.inc'; ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: require_once dirname(__FILE__) .  '/new_db.inc';
                      9: 
                     10: $db->createCollation('NAT', 'strnatcmp');
                     11: 
                     12: $db->exec('CREATE TABLE t (s varchar(4))');
                     13: 
                     14: $stmt = $db->prepare('INSERT INTO t VALUES (?)');
                     15: foreach(array('a1', 'a10', 'a2') as $s){
                     16:        $stmt->bindParam(1, $s);
                     17:        $stmt->execute();
                     18: }
                     19: 
                     20: $defaultSort = $db->query('SELECT s FROM t ORDER BY s');             //memcmp() sort
                     21: $naturalSort = $db->query('SELECT s FROM t ORDER BY s COLLATE NAT'); //strnatcmp() sort
                     22: 
                     23: echo "default\n";
                     24: while ($row = $defaultSort->fetchArray()){
                     25:        echo $row['s'], "\n";
                     26: }
                     27: 
                     28: echo "natural\n";
                     29: while ($row = $naturalSort->fetchArray()){
                     30:        echo $row['s'], "\n";
                     31: }
                     32: 
                     33: $db->close();
                     34: 
                     35: ?>
                     36: --EXPECT--
                     37: default
                     38: a1
                     39: a10
                     40: a2
                     41: natural
                     42: a1
                     43: a2
                     44: a10

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