Listing 14.20. Metoda insertIfNotExists() klasy Img
public static function insertIfNotExists($dane)
{
    $tmp = Doctrine::getTable('Img')->findOneBySlug($dane['slug']);
    if (!$tmp) {
        $tmp = new Img();
        $tmp->fromArray($dane);
        $tmp->save();
    }
    return $tmp;
}
