protected function get_metadatas_ids() { try { return $this->get_data_from_cache(); } catch (\Exception $e) { } $connbas = $this->databox_field->get_connection(); $sql = 'SELECT id FROM metadatas WHERE record_id = :record_id AND meta_struct_id = :meta_struct_id'; $params = [':record_id' => $this->record->get_record_id(), ':meta_struct_id' => $this->databox_field->get_id()]; $stmt = $connbas->prepare($sql); $stmt->execute($params); $ids = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->set_data_to_cache($ids); return $ids; }
public static function create(Application $app, databox_field $databox_field, record_Interface $record, $value, Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null) { $connbas = $databox_field->get_connection(); /** * Check consistency */ if (!$databox_field->is_multi()) { try { $field = $record->get_caption()->get_field($databox_field->get_name()); $values = $field->get_values(); $caption_field_value = array_pop($values); /* @var $value \caption_Field_Value */ $caption_field_value->set_value($value); if (!$vocabulary || !$vocabularyId) { $caption_field_value->removeVocabulary(); } else { $caption_field_value->setVocab($vocabulary, $vocabularyId); } return $caption_field_value; } catch (\Exception $e) { } } $sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value, VocabularyType, VocabularyId) VALUES (null, :record_id, :field, :value, :VocabType, :VocabId)'; $params = [':record_id' => $record->get_record_id(), ':field' => $databox_field->get_id(), ':value' => $value, ':VocabType' => $vocabulary ? $vocabulary->getType() : null, ':VocabId' => $vocabulary ? $vocabularyId : null]; $stmt_ins = $connbas->prepare($sql_ins); $stmt_ins->execute($params); $stmt_ins->closeCursor(); $meta_id = $connbas->lastInsertId(); $caption_field_value = new self($app, $databox_field, $record, $meta_id); $caption_field_value->update_cache_value($value); $record->get_caption()->delete_data_from_cache(); $databox_field->delete_data_from_cache(); $caption_field_value->delete_data_from_cache(); return $caption_field_value; }
public function testGet_connection() { $this->assertInstanceOf('Doctrine\\DBAL\\Driver\\Connection', $this->object_mono->get_connection()); $this->assertInstanceOf('Doctrine\\DBAL\\Driver\\Connection', $this->object_multi->get_connection()); }