function upsert($criteria, $new_object, $options = []) { if (!isset($new_object['crts']) && !$this->first($criteria)) { $new_object['crts'] = $_SERVER['REQUEST_TIME']; } return parent::upsert($criteria, $new_object, $options); }
public function upsert($table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__) { if (!count($rows)) { return true; // nothing to do } if (!is_array(reset($rows))) { $rows = array($rows); } $sequenceData = $this->getSequenceData($table); if ($sequenceData !== false) { // add sequence column to each list of columns, when not set foreach ($rows as &$row) { if (!isset($row[$sequenceData['column']])) { $row[$sequenceData['column']] = $this->addIdentifierQuotes('GET_SEQUENCE_VALUE(\'' . $sequenceData['sequence'] . '\')'); } } } return parent::upsert($table, $rows, $uniqueIndexes, $set, $fname); }
static function set($parent, $child, $collection) { return Database::upsert(FRAMEWORK_COLLECTION_RELATION, array(Node::FIELD_COLLECTION => $collection, 'parent' => $parent, 'child' => $child)); }