got unique index and db_insert() working.