Listing 13.12. Metoda insertIfNotExists() klasy Producent
public function insertIfNotExists($str)
{
    $c = new Criteria();
    $c->add(ProducentPeer::NAZWA, $str);
    $obj = ProducentPeer::doSelectOne($c);
    if (!$obj) {
        $obj = new Producent();
        $obj->setNazwa($str);
        $obj->setSlug(string2slug($str));
        $obj->save();
    }
    return $obj;
}
