本文整理汇总了PHP中Tinebase_Record_RecordSet::getIdsFromMixed方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::getIdsFromMixed方法的具体用法?PHP Tinebase_Record_RecordSet::getIdsFromMixed怎么用?PHP Tinebase_Record_RecordSet::getIdsFromMixed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::getIdsFromMixed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updateForeignKeys
/**
* update foreign key values
*
* @param string $_mode create|update
* @param Tinebase_Record_Interface $_record
*/
protected function _updateForeignKeys($_mode, Tinebase_Record_Interface $_record)
{
if (!empty($this->_foreignTables)) {
foreach ($this->_foreignTables as $modelName => $join) {
if (!(isset($join['field']) || array_key_exists('field', $join))) {
continue;
}
$idsToAdd = array();
$idsToRemove = array();
if (!empty($_record->{$modelName})) {
$idsToAdd = Tinebase_Record_RecordSet::getIdsFromMixed($_record->{$modelName});
}
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
if ($_mode == 'update') {
$select = $this->_db->select();
$select->from(array($join['table'] => $this->_tablePrefix . $join['table']), array($join['field']))->where($this->_db->quoteIdentifier($join['table'] . '.' . $join['joinOn']) . ' = ?', $_record->getId());
Tinebase_Backend_Sql_Abstract::traitGroup($select);
$stmt = $this->_db->query($select);
$currentIds = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
$stmt->closeCursor();
$idsToRemove = array_diff($currentIds, $idsToAdd);
$idsToAdd = array_diff($idsToAdd, $currentIds);
}
if (!empty($idsToRemove)) {
$where = '(' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $join['table'] . '.' . $join['joinOn']) . ' = ?', $_record->getId()) . ' AND ' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $join['table'] . '.' . $join['field']) . ' IN (?)', $idsToRemove) . ')';
$this->_db->delete($this->_tablePrefix . $join['table'], $where);
}
foreach ($idsToAdd as $id) {
$recordArray = array($join['joinOn'] => $_record->getId(), $join['field'] => $id);
$this->_db->insert($this->_tablePrefix . $join['table'], $recordArray);
}
Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
}
}
}
示例2: removeListMember
/**
* remove members from list
*
* @param mixed $_listId
* @param mixed $_membersToRemove
* @return Addressbook_Model_List
*/
public function removeListMember($_listId, $_membersToRemove)
{
/** @var Addressbook_Model_List $list */
$list = $this->get($_listId);
if (empty($_membersToRemove)) {
return $list;
}
$removeMembers = Tinebase_Record_RecordSet::getIdsFromMixed($_membersToRemove);
$idsToRemove = array_intersect($list->members, $removeMembers);
$listId = Tinebase_Record_Abstract::convertId($_listId, $this->_modelName);
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
if (!empty($idsToRemove)) {
$where = '(' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $this->_foreignTables['members']['table'] . '.' . $this->_foreignTables['members']['joinOn']) . ' = ?', $listId) . ' AND ' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $this->_foreignTables['members']['table'] . '.' . $this->_foreignTables['members']['field']) . ' IN (?)', $idsToRemove) . ')';
$this->_db->delete($this->_tablePrefix . $this->_foreignTables['members']['table'], $where);
}
Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
return $this->get($_listId);
}