Ejemplo n.º 1
0
 public function save(Connection $connection)
 {
     $select = $this->selectExecute($connection->getName());
     $id = $select->fetchColumn(0);
     $params = array();
     if ($id) {
         $params['id'] = $id;
         $statement = $this->getUpdate();
     } else {
         $statement = $this->getInsert();
     }
     $params['name'] = $connection->getName();
     $params['offer'] = $connection->getOffer();
     $params['answer'] = $connection->getAnswer();
     $params['candidates'] = serialize($connection->getCandidates());
     $result = $statement->execute($params);
     if (!$result) {
         throw new \Exception("failed to save connection record.");
     }
 }
Ejemplo n.º 2
0
 public function save(Connection $connection)
 {
     $connections = $this->getAllConnections();
     $connections[$connection->getName()] = $connection;
     $this->saveAllConnections($connections);
 }