Example #1
0
 /**
  * Saves any changes to this record in the database on the Database Server.
  *
  * @return boolean TRUE, if successful.
  *         object.
  * @throws FileMakerException
  */
 public function commit()
 {
     if ($this->fm->getProperty('prevalidate')) {
         $validation = $this->validate();
         if (FileMaker::isError($validation)) {
             return $validation;
         }
     }
     if (is_null($this->parent)) {
         if ($this->recordId) {
             return $this->_commitEdit();
         } else {
             return $this->_commitAdd();
         }
     } else {
         if (!$this->parent->getRecordId()) {
             throw new FileMakerException($this->fm, 'You must commit the parent record first before you can commit its children.');
         }
         if ($this->recordId) {
             return $this->_commitEditChild();
         } else {
             return $this->_commitAddChild();
         }
     }
 }
Example #2
0
 public function execute()
 {
     $params = $this->_getCommandParams();
     $this->_setSortParams($params);
     $this->_setRangeParams($params);
     $this->_setRelatedSetsFilters($params);
     if (count($this->_findCriteria) || $this->recordId) {
         $params['-find'] = true;
     } else {
         $params['-findall'] = true;
     }
     if ($this->recordId) {
         $params['-recid'] = $this->recordId;
     }
     if ($this->_operator) {
         $params['-lop'] = $this->_operator;
     }
     foreach ($this->_findCriteria as $field => $value) {
         $params[$field] = $value;
     }
     $result = $this->fm->execute($params);
     if (FileMaker::isError($result)) {
         return $result;
     }
     return $this->_getResult($result);
 }
Example #3
0
 /**
  * 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 this method returns 
  * an Error object. 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.
  *
  * @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.
  */
 public function setFieldFromTimestamp($field, $timestamp, $repetition = 0)
 {
     $layout =& $this->fm->getLayout($this->_layout);
     if (FileMaker::isError($layout)) {
         return $layout;
     }
     $field =& $layout->getField($fieldname);
     if (FileMaker::isError($field)) {
         return $field;
     }
     switch ($field->getResult()) {
         case 'date':
             return $this->setField($fieldname, date('m/d/Y', $timestamp), $repetition);
         case 'time':
             return $this->setField($fieldname, date('H:i:s', $timestamp), $repetition);
         case 'timestamp':
             return $this->setField($fieldname, date('m/d/Y H:i:s', $timestamp), $repetition);
     }
     throw new FileMakerException($this->fm, 'Only time, date, and timestamp fields can be set to the value of a timestamp.');
 }