public function insertIfNotExists($data)
{
$select = $this->select()
->from('aktor', array('aktor_id'))
->where('imie = ?', $data['imie'])
->where('nazwisko = ?', $data['nazwisko']);
if ($aktor = $this->fetchRow($select)) {
return $aktor->aktor_id;
}
return $this->createRow($data)->save();
}
Listing 18.11. Metoda insertIfNotExists() klasy Application_Model_DbTable_Aktor
Rozdział 18. Relacje n:m (wiele do wielu)