/** * Sets the new value for a date, time, or timestamp field from a * UNIX timestamp value. * * If the field is not a date or time field, then returns an error. * Otherwise, returns TRUE. * * If layout data for the target of this command has not already * been loaded, calling this method loads layout data so that * the type of the field can be checked. * * @todo use DateTime instead of date() to handle pre-epoch timestamps * * @param string $field Name of the field to set. * @param string $timestamp Timestamp value. * @param integer $repetition Field repetition number to set. * Defaults to the first repetition. * * @return string * @throws FileMakerException */ public function setFieldFromTimestamp($field, $timestamp, $repetition = 0) { $fieldType = $this->layout->getField($field); if (FileMaker::isError($fieldType)) { return $fieldType; } switch ($fieldType->getResult()) { case 'date': return $this->setField($field, date('m/d/Y', $timestamp), $repetition); case 'time': return $this->setField($field, date('H:i:s', $timestamp), $repetition); case 'timestamp': return $this->setField($field, date('m/d/Y H:i:s', $timestamp), $repetition); } $error = new FileMakerException($this->fm, 'Only time, date, and timestamp fields can be set to the value of a timestamp.'); if ($this->fm->getProperty('errorHandling') === 'default') { return $error; } throw $error; }
/** * Add extended infos to a Layout object * * @param Layout $layout * @return FileMakerException * @throws FileMakerException */ public function setExtendedInfo(Layout $layout) { if (!$this->_isParsed) { $error = new FileMakerException($this->_fm, 'Attempt to set extended information before parsing data.'); if ($this->_fm->getProperty('errorHandling') === 'default') { return $error; } throw $error; } $layout->valueLists = $this->_valueLists; $layout->valueListTwoFields = $this->_valueListTwoFields; foreach ($this->_fields as $fieldName => $fieldInfos) { try { $field = $layout->getField($fieldName); if (!FileMaker::isError($field)) { $field->styleType = $fieldInfos['styleType']; $field->valueList = $fieldInfos['valueList'] ? $fieldInfos['valueList'] : null; } } catch (\Exception $e) { //Field may be missing when it is stored in a portal, ommit error } } }