Listing 13.11. | |
| ROZDZIAŁ: | 13. Zagadnienia dodatkowe dotyczące warstw M oraz V |
| TXT: | listing-13-11.txt |
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;
}