Exemplo n.º 1
0
 /**
  * select exactly one record from database
  * @param $encoded_key_string string unique identifier of requested ListTableItem
  * @return array array containing exactly one ListTableItem (which is an array)
  */
 function select_record($encoded_key_string)
 {
     $this->_log->trace("selecting record form ListTable (encoded_key_string=" . $encoded_key_string . ")");
     # call parent select_record()
     $record = parent::select_record($encoded_key_string, $this->db_field_names);
     if (count($record) != 0) {
         # get notes
         foreach ($this->db_field_names as $db_field_name) {
             if ($this->fields[$db_field_name][1] == FIELD_TYPE_DEFINITION_NOTES_FIELD) {
                 if ($record[$db_field_name] > 0) {
                     $result = $this->_list_table_note->select($record[DB_ID_FIELD_NAME], $db_field_name);
                     if (count($result) == 0 || count($result) != $record[$db_field_name]) {
                         $this->_log->warn("unexpected number of notes found (expected=" . $record[$db_field_name] . ", found=" . count($result) . ")");
                         $record[$db_field_name] = $result;
                     } else {
                         $record[$db_field_name] = $result;
                     }
                 } else {
                     $record[$db_field_name] = array();
                 }
             }
             if ($this->fields[$db_field_name][1] == FIELD_TYPE_DEFINITION_ATTACHMENTS) {
                 if ($record[$db_field_name] > 0) {
                     $result = $this->_list_table_attachment->select($record[DB_ID_FIELD_NAME]);
                     if (count($result) == 0 || count($result) != $record[$db_field_name]) {
                         $this->_log->warn("unexpected number of attachments found (expected=" . $record[$db_field_name] . ", found=" . count($result) . ")");
                         $record[$db_field_name] = $result;
                     } else {
                         $record[$db_field_name] = $result;
                     }
                 } else {
                     $record[$db_field_name] = array();
                 }
             }
         }
         $this->_log->trace("selected record form ListTable record");
         return $record;
     } else {
         return $record;
     }
 }