1--TEST-- 2PDO_sqlite: Testing sqliteCreateCollation() 3--EXTENSIONS-- 4pdo_sqlite 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 test_pdo_sqlite_createcollation (id INT AUTO INCREMENT, name TEXT)'); 12 13$db->query('INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, "1"), (NULL, "2"), (NULL, "10")'); 14 15$db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); }); 16 17$result = $db->query('SELECT name FROM test_pdo_sqlite_createcollation ORDER BY name COLLATE MYCOLLATE'); 18foreach ($result as $row) { 19 echo $row['name'] . "\n"; 20} 21 22$result = $db->query('SELECT name FROM test_pdo_sqlite_createcollation ORDER BY name'); 23foreach ($result as $row) { 24 echo $row['name'] . "\n"; 25} 26 27?> 28--EXPECT-- 291 302 3110 321 3310 342 35