本文整理汇总了PHP中Sequence::getNextSequenceValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Sequence::getNextSequenceValues方法的具体用法?PHP Sequence::getNextSequenceValues怎么用?PHP Sequence::getNextSequenceValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence::getNextSequenceValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
public function flush() {
if (!isset($this->recordsHolder)) {
return;
}
$datasetName = NameSpaceHelper::addNameSpace(DATASOURCE_NAME__HEALTH_MONITORING, 'hm_trails');
// generating and assigning primary key
$identifiers = Sequence::getNextSequenceValues($datasetName, count($this->recordsHolder->records));
foreach ($this->recordsHolder->records as $index => $recordInstance) {
$recordInstance->setColumnValue(0, $identifiers[$index]);
}
// storing data in the database
$dataManipulationController = data_controller_dml_get_instance();
$dataManipulationController->insertDatasetRecordBatch($datasetName, $this->recordsHolder);
$this->recordsHolder = NULL;
}
示例2: generateAndStoreIdentifiers
protected function generateAndStoreIdentifiers($lookupDatasetName, array $uniqueSetColumns, array $nonKeyColumns = NULL, $sequenceName, array &$lookupValues) {
$dataManipulationController = data_controller_dml_get_instance();
$metamodel = data_controller_get_metamodel();
$lookupDataset = $metamodel->getDataset($lookupDatasetName);
$identifierColumnName = $lookupDataset->getKeyColumn()->name;
$lookupCacheKey = $this->prepareLookupCacheKey($lookupDataset->name);
// preparing insert operation meta data
$recordsHolder = new IndexedRecordsHolder();
$recordsHolder->recordMetaData = new RecordMetaData();
// registering 'identifier' column
$column = $recordsHolder->recordMetaData->registerColumn($identifierColumnName);
$column->initializeTypeFrom(Sequence::getSequenceColumnType());
// registering columns which represent lookup key
foreach ($uniqueSetColumns as $uniqueSetColumn) {
$column = $recordsHolder->recordMetaData->registerColumn($uniqueSetColumn->name);
$column->initializeTypeFrom($uniqueSetColumn->type);
$column->key = TRUE;
}
// registering non key columns
if (isset($nonKeyColumns)) {
foreach ($nonKeyColumns as $nonKeyColumn) {
$column = $recordsHolder->recordMetaData->registerColumn($nonKeyColumn->name);
$column->initializeTypeFrom($nonKeyColumn->type);
}
}
// generating identifiers for source table
$identifiers = Sequence::getNextSequenceValues($sequenceName, count($lookupValues));
// preparing records for insert operation
foreach ($lookupValues as $lookupKey => $lookupValue) {
$identifier = array_pop($identifiers);
$record = array($identifier);
foreach ($uniqueSetColumns as $uniqueSetColumn) {
$columnName = $uniqueSetColumn->name;
$record[] = $lookupValue->$columnName;
}
if (isset($nonKeyColumns)) {
$lookupValue = $lookupValues[$lookupKey];
foreach ($nonKeyColumns as $nonKeyColumn) {
$record[] = $lookupValue->{$nonKeyColumn->name};
}
}
$recordInstance = $recordsHolder->initiateRecordInstance();
$recordInstance->initializeFrom($record);
$recordsHolder->registerRecordInstance($recordInstance);
$lookupValue->identifier = $identifier;
$this->cachedIdentifiers[$lookupCacheKey][$lookupKey] = $identifier;
}
$this->freeSpaceInIdentifierCache($lookupDataset->name);
// storing 'missing' records
$dataManipulationController->insertDatasetRecordBatch($lookupDataset->name, $recordsHolder);
}