Annotation of embedaddon/php/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: PDO_sqlite: Testing sqliteCreateCollation()
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: $db = new pdo('sqlite::memory:');
                      9: $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                     10: 
                     11: $db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
                     12: 
                     13: $db->query('INSERT INTO foobar VALUES (NULL, "1")');
                     14: $db->query('INSERT INTO foobar VALUES (NULL, "2")');
                     15: $db->query('INSERT INTO foobar VALUES (NULL, "10")');
                     16: 
                     17: $db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); });
                     18: 
                     19: $result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE');
                     20: foreach ($result as $row) {
                     21:        echo $row['name'] . "\n";
                     22: }
                     23: 
                     24: $result = $db->query('SELECT name FROM foobar ORDER BY name');
                     25: foreach ($result as $row) {
                     26:   echo $row['name'] . "\n";
                     27: }
                     28: 
                     29: $db->query('DROP TABLE foobar');
                     30: 
                     31: ?>
                     32: --EXPECTF--
                     33: 1
                     34: 2
                     35: 10
                     36: 1
                     37: 10
                     38: 2

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