Exemple #1
0
 /**
  * Store an xtended (unspecified, vendor extension) property.
  * @param Property $property The property to store.
  * @param string $uid The uid of the CONTACT to associate the new
  * record with.
  * @return integer The ID of the newly created record.
  */
 private function storeXtendedProperty(Property $property, $uid)
 {
     assert($this->connection !== null);
     assert(!empty($uid));
     assert(is_string($uid));
     $stmt = $this->prepareCannedQuery('store', 'xtended');
     $stmt->bindValue(':uid', $uid);
     $stmt->bindValue(':name', $property->getName());
     $stmt->bindValue(':value', $property->getValue());
     $stmt->bindValue(':valuetype', $property->getValueType(false));
     $stmt->bindValue('pref', $property->getPref(false), \PDO::PARAM_INT);
     $stmt->bindValue(':mediatype', $property->getMediaType());
     $stmt->bindValue(':propGroup', $property->getGroup());
     $stmt->execute();
     $propertyID = $this->connection->lastInsertId();
     $this->associateTypes($property, $propertyID, 'xtended');
     return $propertyID;
 }
 /**
  * A sort-function suitable for use with \usort() or \uasort() which
  * compares the PREF parameter.
  * @param Property $a
  * @param Property $b
  * @return int -1, 0, or 1 if $a sorts less than, equal to, or greater than
  * $b.
  * @see Property::comparePref()
  */
 public function comparePref(Property $a, Property $b)
 {
     if ($a->getPref() == $b->getPref()) {
         return 0;
     } elseif ($a->getPref() < $b->getPref()) {
         return -1;
     } else {
         return 1;
     }
 }