Skip to content

Instantly share code, notes, and snippets.

View 10nin's full-sized avatar
🔥
真空に火を点ける

10nin 10nin

🔥
真空に火を点ける
View GitHub Profile
@bohwaz
bohwaz / php_sqlite_rank.php
Created November 10, 2011 16:09
Pure PHP rank function for SQLite FTS4 (adapted from SQLite doc)
<?php
/*
Adapted from C function available at http://www.sqlite.org/fts3.html#appendix_a
Use like this:
$db = new SQLite3('database.db');
$db->createFunction('rank', 'sql_rank');
$db->query('CREATE VIRTUAL TABLE products USING fts4 (id INTEGER, title TEXT, description TEXT);');
$db->query('SELECT * FROM products WHERE products MATCH \'Computer\' ORDER BY rank(matchinfo(products), 0, 1.0, 0.5) DESC;');