Merge pull request #1001 from romainneutron/fix-1707

[Ready][3.8] Fix #1707 : Update technical informations and metadata fields on record substitution
This commit is contained in:
Nicolas Le Goff
2014-03-02 19:14:06 +01:00
12 changed files with 297 additions and 261 deletions

View File

@@ -180,7 +180,7 @@ class caption_field implements cache_cacheableInterface
/**
*
* @return array
* @return \caption_Field_Value[]
*/
public function get_values()
{

View File

@@ -254,7 +254,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
public function get_field($fieldname)
{
foreach ($this->get_fields(null, true) as $meta_struct_id => $field) {
foreach ($this->get_fields(null, true) as $field) {
if ($field->get_name() == $fieldname) {
return $field;
}
@@ -263,6 +263,17 @@ class caption_record implements caption_interface, cache_cacheableInterface
throw new \Exception('Field not found');
}
public function has_field($fieldname)
{
foreach ($this->get_fields(null, true) as $field) {
if ($field->get_name() == $fieldname) {
return true;
}
}
return false;
}
/**
*
* @param type $label

View File

@@ -1371,7 +1371,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this;
}
$sql = 'REPLACE INTO technical_datas (id, record_id, name, value)
$sql = 'DELETE FROM technical_datas WHERE record_id = :record_id';
$stmt = $this->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor();
$sql = 'INSERT INTO technical_datas (id, record_id, name, value)
VALUES (null, :record_id, :name, :value)';
$stmt = $this->get_databox()->get_connection()->prepare($sql);