forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
createCollation() for pdo_sqlite as well
Closes bug #55226
- Loading branch information
Showing
3 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--TEST-- | ||
PDO_sqlite: Testing sqliteCreateCollation() | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> | ||
--FILE-- | ||
<?php | ||
|
||
$db = new pdo('sqlite::memory:'); | ||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
|
||
$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)'); | ||
|
||
$db->query('INSERT INTO foobar VALUES (NULL, "1")'); | ||
$db->query('INSERT INTO foobar VALUES (NULL, "2")'); | ||
$db->query('INSERT INTO foobar VALUES (NULL, "10")'); | ||
|
||
$db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); }); | ||
|
||
$result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE'); | ||
foreach ($result as $row) { | ||
echo $row['name'] . "\n"; | ||
} | ||
|
||
$result = $db->query('SELECT name FROM foobar ORDER BY name'); | ||
foreach ($result as $row) { | ||
echo $row['name'] . "\n"; | ||
} | ||
|
||
$db->query('DROP TABLE foobar'); | ||
|
||
?> | ||
--EXPECTF-- | ||
1 | ||
2 | ||
10 | ||
1 | ||
10 | ||
2 |