Sqliteで重複レコードを削除するには。

Sqlite3で実行。idとtitleで比較。

<?php
require_once 'Zend/Db.php';
$db = Zend_Db::factory('Pdo_Sqlite', array(
    'dbname'           => "sample.db"
));
$sql  = "CREATE TABLE temptable as SELECT * FROM testtable GROUP BY id, title";
$db->getConnection()->exec($sql);
$sql  = "DROP TABLE testtable";
$db->getConnection()->exec($sql);
$sql  = "ALTER TABLE temptable RENAME TO testtable";
$db->getConnection()->exec($sql);
echo"done";