We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to avoid saving duplicate entries into db

Is there any efficient way to avoid saving duplicate entries into db while reading data from exl row??

Making a column unique or do a query to check if data exists?

Unique column ? Or use Uniqueness validator.

edited Dec '16
<?php

$check_existing_record = Model::findFirst(array("input1 = :input1: AND input2 = :input2: AND input3 = :input3: etc ",
"bind" => array("input1" => $input1, "input2" => $input2, "input3" => $input3 etc)
));
if($check_existing_record == false)
{
//keep saving uniqe record
}