本文整理汇总了PHP中ArrayHelper::appendValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::appendValue方法的具体用法?PHP ArrayHelper::appendValue怎么用?PHP ArrayHelper::appendValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::appendValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeValuesImpl
protected function storeValuesImpl(array $values, $expirationTime) {
$errorCacheEntryNames = NULL;
$adjustedExpirationTime = $expirationTime;
if (!isset($adjustedExpirationTime)) {
$adjustedExpirationTime = 0;
}
$storableValues = $deletableCacheEntryNames = NULL;
foreach ($values as $cacheEntryName => $value) {
if (isset($value)) {
$storableValues[$cacheEntryName] = $value;
}
else {
$deletableCacheEntryNames[] = $cacheEntryName;
}
}
if (isset($deletableCacheEntryNames)) {
foreach ($deletableCacheEntryNames as $deletableCacheEntryName) {
$result = $this->memcached->delete($deletableCacheEntryName);
if (($result === FALSE) && ($this->memcached->getResultCode() != Memcached::RES_NOTFOUND)) {
$errorCacheEntryNames[] = $deletableCacheEntryName;
LogHelper::log_error(t(
'[@cacheType] Internal error during value deletion: @message',
array('@cacheType' => self::CACHE__TYPE, '@message' => $this->memcached->getResultMessage())));
}
}
}
if (isset($storableValues)) {
$result = $this->memcached->setMulti($storableValues, $adjustedExpirationTime);
if ($result === FALSE) {
LogHelper::log_error(t(
'[@cacheType] Internal error during value storing: @message',
array('@cacheType' => self::CACHE__TYPE, '@message' => $this->memcached->getResultMessage())));
ArrayHelper::appendValue($errorCacheEntryNames, array_keys($storableValues));
}
}
return $errorCacheEntryNames;
}
示例2: insertOrUpdateOrDeleteDatasetRecords
//.........这里部分代码省略.........
}
}
// loading existing records ... if any
$existingRecordFormatter = new QueryKeyResultFormatter($keyColumnNames);
$existingRecords = $existingRecordFormatter->formatRecords($datasourceQueryHandler->queryDataset($callcontext, $queryRequest));
// sorting out records for insert, update and delete operations
$keyedRecords = $insertedRecordKeys = $updatedRecordKeys = $deletedRecordKeys = NULL;
foreach ($request->recordsHolder->records as $record) {
$keyParts = NULL;
foreach ($keyColumnNames as $keyColumnIndex => $keyColumnName) {
$keyColumnIdentifier = $isRecordIndexed ? $keyColumnIndex : $keyColumnName;
$keyParts[] = $record->getColumnValue($keyColumnIdentifier, TRUE);
}
$key = ArrayHelper::prepareCompositeKey($keyParts);
$keyedRecords[$key] = $record;
// checking if the record has to be deleted
$isDeletable = TRUE;
if (isset($nonkeyColumnNames)) {
foreach ($nonkeyColumnNames as $columnIndex => $columnName) {
$columnIdentifier = $isRecordIndexed ? $columnIndex : $columnName;
if ($record->getColumnValue($columnIdentifier) != NULL) {
$isDeletable = FALSE;
break;
}
}
}
else {
// the dataset has NO non-key columns. We should not delete these records
$isDeletable = FALSE;
}
if ($isDeletable) {
unset($insertedRecordKeys[$key]);
unset($updatedRecordKeys[$key]);
// the record physically present in database and needs to be deleted
if (isset($existingRecords[$key])) {
unset($existingRecords[$key]);
$deletedRecordKeys[$key] = TRUE;
}
}
elseif (isset($insertedRecordKeys[$key])) {
// the key has been already used to insert a record within this batch. This record needs to be part of update operation
$updatedRecordKeys[$key] = TRUE;
}
elseif (isset($existingRecords[$key])) {
$updatedRecordKeys[$key] = TRUE;
}
else {
$insertedRecordKeys[$key] = TRUE;
}
}
$sqls = NULL;
// deleting existing records
$deletedRecordCount = 0;
if (isset($deletedRecordKeys)) {
$deleteRecordHolder = $this->prepareRecordHolder($request, $keyedRecords, $deletedRecordKeys);
// preparing request
$deleteRequest = new DatasetDeleteRequest($request->datasetName, $deleteRecordHolder);
// preparing statements to delete records from the database
ArrayHelper::appendValue($sqls, $this->prepareDeleteDatasetRecordStatements($callcontext, $deleteRequest));
$deletedRecordCount = count($deleteRecordHolder->records);
}
// inserting new records
$insertedRecordCount = 0;
if (isset($insertedRecordKeys)) {
$insertRecordHolder = $this->prepareRecordHolder($request, $keyedRecords, $insertedRecordKeys);
// preparing request
$insertRequest = new DatasetInsertRequest($request->datasetName, $insertRecordHolder);
// preparing statements to insert records into the database
ArrayHelper::appendValue($sqls, $this->prepareInsertDatasetRecordStatements($callcontext, $insertRequest));
$insertedRecordCount = count($insertRecordHolder->records);
}
// updating existing records
$updatedRecordCount = 0;
if (isset($updatedRecordKeys)) {
$updateRecordHolder = $this->prepareRecordHolder($request, $keyedRecords, $updatedRecordKeys);
// preparing request
$updateRequest = new DatasetUpdateRequest($request->datasetName, $updateRecordHolder);
// preparing statements to update records in the database
ArrayHelper::appendValue($sqls, $this->prepareUpdateDatasetRecordStatements($callcontext, $updateRequest));
$updatedRecordCount = count($updateRecordHolder->records);
}
$affectedRecordCount = isset($sqls) ? $this->executeManipulationStatementBatch($datasource, $sqls) : 0;
if (($insertedRecordCount + $updatedRecordCount + $deletedRecordCount) < $affectedRecordCount) {
throw new IllegalStateException(t('Number of affected records is greater than expected number of inserted, updated and deleted records'));
}
return array($insertedRecordCount, $updatedRecordCount, $deletedRecordCount);
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:101,代码来源:AbstractSQLDataSourceManipulationHandler.php
示例3: storeValuesImpl
protected function storeValuesImpl(array $values, $expirationTime) {
$errorCacheEntryNames = NULL;
$adjustedExpirationTime = $expirationTime;
if (!isset($adjustedExpirationTime)) {
$adjustedExpirationTime = 0;
}
$storableValues = $deletableCacheEntryNames = NULL;
foreach ($values as $cacheEntryName => $value) {
if (isset($value)) {
$storableValues[$cacheEntryName] = $value;
}
else {
$deletableCacheEntryNames[] = $cacheEntryName;
}
}
if (isset($deletableCacheEntryNames)) {
foreach ($deletableCacheEntryNames as $deletableCacheEntryName) {
$result = apc_delete($deletableCacheEntryName);
if ($result === FALSE) {
$errorCacheEntryNames[] = $deletableCacheEntryName;
}
}
}
if (isset($storableValues)) {
$unused = FALSE;
$result = apc_store($storableValues, $unused, $adjustedExpirationTime);
if ($result === FALSE) {
ArrayHelper::appendValue($errorCacheEntryNames, array_keys($storableValues));
}
}
return $errorCacheEntryNames;
}