public function testLoadRelation() { $termType = new KVDthes_TermType('PT', 'voorkeursterm'); $term2 = new KVDthes_TestTerm(508, $this->sessie, 'kapellen', $termType, 'bouwkundig erfgoed'); $this->object->loadRelation(new KVDthes_Relation(KVDthes_Relation::REL_RT, $term2)); $this->object->setLoadState(KVDthes_Term::LS_REL); $this->object->setLoadState(KVDthes_Term::LS_MATCH); $term2->setLoadState(KVDthes_Term::LS_REL); $this->assertEquals(1, count($this->object->getRelations())); $this->assertEquals(1, count($term2->getRelations())); }
/** * insertRelations * * @param KVDthes_Term $term * @return void */ private function insertRelations(KVDthes_Term $term) { $sql = sprintf('INSERT INTO %s.relation ( thesaurus_id, id_from, relation_type, id_to) VALUES ( %s, ?, ?, ?)', $this->parameters['schema'], $this->parameters['thesaurus_id']); if (count($term->getRelations()) > 0) { $stmt = $this->conn->prepare($sql); $stmt->bindValue(1, $term->getId(), PDO::PARAM_INT); foreach ($term->getRelations() as $rel) { $stmt->bindValue(2, $rel->getType(), PDO::PARAM_STR); $stmt->bindValue(3, $rel->getTerm()->getId(), PDO::PARAM_INT); $stmt->execute(); } } }