32 new Main\Entity\IntegerField(
'SRC_ENTITY_TYPE_ID', [
'primary' =>
true ]),
33 new Main\Entity\IntegerField(
'SRC_ENTITY_ID', [
'primary' =>
true ]),
34 new Main\Entity\IntegerField(
'DST_ENTITY_TYPE_ID', [
'primary' =>
true ]),
35 new Main\Entity\IntegerField(
'DST_ENTITY_ID', [
'primary' =>
true ]),
36 new Main\Entity\DatetimeField(
'CREATED_TIME'),
37 new Main\Entity\DatetimeField(
'LAST_UPDATED_TIME')
41 public static function upsert(array $data)
43 $srcEntityTypeID = isset($data[
'SRC_ENTITY_TYPE_ID']) ? (int)$data[
'SRC_ENTITY_TYPE_ID'] : \CCrmOwnerType::Undefined;
44 $srcEntityID = isset($data[
'SRC_ENTITY_ID']) ? (int)$data[
'SRC_ENTITY_ID'] : 0;
46 $dstEntityTypeID = isset($data[
'DST_ENTITY_TYPE_ID']) ? (int)$data[
'DST_ENTITY_TYPE_ID'] : \CCrmOwnerType::Undefined;
47 $dstEntityID = isset($data[
'DST_ENTITY_ID']) ? (int)$data[
'DST_ENTITY_ID'] : 0;
49 $now = Main\Type\DateTime::createFromTimestamp(time() + \CTimeZone::GetOffset());
52 'SRC_ENTITY_TYPE_ID' => $srcEntityTypeID,
53 'SRC_ENTITY_ID' => $srcEntityID,
54 'DST_ENTITY_TYPE_ID' => $dstEntityTypeID,
55 'DST_ENTITY_ID' => $dstEntityID,
56 'CREATED_TIME' => $now,
57 'LAST_UPDATED_TIME' => $now
61 'LAST_UPDATED_TIME' => $now,
62 'SRC_ENTITY_TYPE_ID' => $srcEntityTypeID,
63 'SRC_ENTITY_ID' => $srcEntityID,
64 'DST_ENTITY_TYPE_ID' => $dstEntityTypeID,
65 'DST_ENTITY_ID' => $dstEntityID
68 $connection = Main\Application::getConnection();
69 $queries = $connection->getSqlHelper()->prepareMerge(
70 static::getTableName(),
81 foreach($queries as $query)
83 $connection->queryExecute($query);