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