Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10190 invoked from network); 23 Jan 2012 22:28:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2012 22:28:44 -0000 Authentication-Results: pb1.pair.com header.from=macdewar@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=macdewar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: macdewar@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:43141] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4F/8D-36418-C1FDD1F4 for ; Mon, 23 Jan 2012 17:28:44 -0500 Received: by lahg1 with SMTP id g1so810552lah.29 for ; Mon, 23 Jan 2012 14:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=1/Ff/YblSM6QOD9HYQYh7VtcUS2FgjwkOQukf9hge4o=; b=XA8PsB29X8VZAi3VsCUvhuzchjdu7hNDn+dlYlZNatEczGKEBrHyGkhlsvK2V26jLY gwIXsTzRdM6GttNK+qd77clHFSirmIIsBq1gsp6dfuB3oJyw68KnMa4h1zlJ92AMU3u2 WNKZgA5C0wPAhtZNjbPi+mZf3KI9W/XSrdfLA= MIME-Version: 1.0 Received: by 10.112.41.169 with SMTP id g9mr2685534lbl.94.1327357721046; Mon, 23 Jan 2012 14:28:41 -0800 (PST) Received: by 10.112.25.35 with HTTP; Mon, 23 Jan 2012 14:28:41 -0800 (PST) Date: Mon, 23 Jan 2012 18:28:41 -0400 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: SQLite3 class missing createCollation() From: macdewar@gmail.com (b dewar) Hi I initially sent this to php-db, but I guess it really belongs on internals= . The C API for SQLite3 has an sqlite3_create_collation() feature that's missing from PHP's SQLite3 class API. I'm working on a patch that adds the SQLite3::createCollation(string collation_name, mixed callback) method.=C2=A0 This allows registering a PHP function as a comparator for the database to use while collating data. The callback passed to createCollation() should act like strcmp(), i.e. it should accept two strings and return an integer indicating their relative sort order. e.g. createCollation('NATURAL_SORT', 'strnatcmp'); $db->exec("CREATE TABLE filenames (fname varchar(32));"); $stmt =3D $db->prepare("INSERT INTO filenames VALUES (?);"); foreach($filenames as $fname){ =C2=A0 $stmt->bindParam(1, $fname); =C2=A0 $stmt->execute(); } $result =3D $db->query("SELECT fname FROM filenames ORDER BY fname COLLATE NATURAL_SORT;"); while($row =3D $result->fetchArray()){ =C2=A0 echo $row['fname'], "\n"; } $db->close(); ?> Output: aa.png ab1.png ab2.png ab3.png ab10.png ab11.png ac.png I've built 5.3.9 with my patch on Ubuntu on x86_64, and it works as expected. I've never submitted a patch for PHP before, so I could use some advice/hand-holding on the process. Thanks, Brad