public function save(Address $address) { $data = $address->getRawData(); if ($address->getAddressId() > 0) { $id = $address->getAddressId(); $this->tableGateway->update($data, array('aufri_address_id' => $id)); } else { if (!$this->tableGateway->insert($data)) { throw new \Exception("Could not new row {$id}"); } $id = (int) $this->tableGateway->lastInsertValue; } return $this->getOne(array('aufri_address_id' => $id)); }