本文整理汇总了PHP中ArrayUtils::arrayMultiColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::arrayMultiColumn方法的具体用法?PHP ArrayUtils::arrayMultiColumn怎么用?PHP ArrayUtils::arrayMultiColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils::arrayMultiColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multiGet
public function multiGet($noderefs, NodePartials $nodePartials, $forceReadWrite = false, $checkJumpPermissions = false, $allowDeleted = false)
{
// foreach((array)$noderefs as $nodeRef)
// $this->NodeEvents->fireNodeEvents('get', '', &$nodeRef);
if (empty($noderefs)) {
return array();
}
$results = array();
$idField = 'ID';
$connectionCouplets = $this->getResolvedConnectionCouplets(is_array($noderefs) ? $noderefs : array($noderefs), $forceReadWrite);
foreach ($connectionCouplets as $connectionCouplet) {
$db = $connectionCouplet->getConnection();
$tableToSlugs = $connectionCouplet->getAttribute('tablesToSlugs');
foreach ($tableToSlugs as $table => $tableInfo) {
extract($tableInfo);
if ($checkJumpPermissions && !$this->NodePermissions->check('get', $tableNodeRef, $nodePartials, true)) {
continue;
}
foreach (array_chunk($slugs, 1000) as $slugs) {
$rows = $this->multiGetFromDB($db, $tableid, $table, $tableNodeRef, $slugs, false, $forceReadWrite, $allowDeleted);
if (!empty($rows)) {
$ids = ArrayUtils::arrayMultiColumn($rows, $idField);
$outTags = $this->NodeTagsDAO->findOutTags($db, $tableNodeRef, $ids, $nodePartials->getOutPartials(), $forceReadWrite, $checkJumpPermissions, $nodePartials->getRestrictedOutPartials(), $nodePartials->isResolveLinks());
$inTags = $this->NodeTagsDAO->findInTags($db, $tableNodeRef, $ids, $nodePartials->getInPartials(), $forceReadWrite, $checkJumpPermissions, $nodePartials->getRestrictedInPartials(), $nodePartials->isResolveLinks());
$meta = $this->NodeMetaDAO->findMeta($db, $tableNodeRef, $ids, $nodePartials->getMetaPartials(), $forceReadWrite, $nodePartials->getRestrictedMetaPartials());
foreach ($rows as $nodeRefString => $row) {
$row->setNodePartials($nodePartials);
if (isset($meta[$row[$idField]])) {
$row->setMetas($meta[$row[$idField]]);
}
if (isset($outTags[$row[$idField]])) {
$row->setOutTags($outTags[$row[$idField]]);
}
if (isset($inTags[$row[$idField]])) {
$row->setInTags($inTags[$row[$idField]]);
}
//$this->NodeMapper->populateNodeCheaters($row);
$results[$nodeRefString] = $row;
}
unset($ids);
unset($outTags);
unset($inTags);
unset($meta);
}
unset($rows);
}
unset($slugs);
}
unset($tableToSlugs);
}
unset($connectionCouplets);
if (!empty($results) && !is_array($noderefs)) {
return current($results);
}
return $results;
}
示例2: getNodes
/**
* {@inheritdoc}
*/
public function getNodes(NodeRef $nodeRef, $slugs, $localOnly = false)
{
$cacheKeys = array();
$nodeRefPart = $nodeRef->getElement()->getSlug();
foreach ((array) $slugs as $slug) {
$cacheKeys[] = 'node-' . $nodeRefPart . ':' . $slug;
}
if (!empty($cacheKeys)) {
if (($cachedRows = $this->multiGet($cacheKeys, $localOnly)) && !empty($cachedRows)) {
$cachedSlugs = ArrayUtils::arrayMultiColumn($cachedRows, 'Slug');
return array($cachedSlugs, $cachedRows);
}
}
return array(array(), array());
}
示例3: findTags
//.........这里部分代码省略.........
foreach ($connectionCouplets as $connectionCouplet) {
$db = $connectionCouplet->getConnection();
$tableToSlugs = $connectionCouplet->getAttribute('tablesToSlugs');
foreach ($tableToSlugs as $table => $tableInfo) {
extract($tableInfo);
$rowRefKey = $element->getSlug();
$partialJump = false;
$newNodePartials = null;
if (array_key_exists($rowRefKey, $addlParams)) {
$partialJump = true;
$addl = $addlParams[$rowRefKey];
$newNodePartials = new NodePartials();
if (array_key_exists('OutTags.select', $addl)) {
$newNodePartials->setOutPartials(implode(',', array_unique($addl['OutTags.select'])));
}
if (array_key_exists('InTags.select', $addl)) {
$newNodePartials->setInPartials(implode(',', array_unique($addl['InTags.select'])));
}
if (array_key_exists('Meta.select', $addl)) {
$newNodePartials->setMetaPartials(implode(',', array_unique($addl['Meta.select'])));
}
}
if ($checkJumpPermissions && !$this->NodePermissions->check('get', $tableNodeRef, $newNodePartials, true)) {
continue;
}
$foundRows = $this->multiGetFromDB($db, $tableid, $table, $tableNodeRef, $slugs, false, $forceReadWrite, false);
if ($partialJump && !empty($foundRows)) {
$this->Logger->debug('Partials jump on ' . $tableNodeRef->getElement()->getName());
$aoutTags = array();
$ainTags = array();
$ameta = array();
$this->Benchmark->start('partial-jump');
$idField = 'ID';
$pids = ArrayUtils::arrayMultiColumn($foundRows, $idField);
if ($newNodePartials->hasOutPartials()) {
$aoutTags = $this->findOutTags($db, $tableNodeRef, $pids, $newNodePartials->getOutPartials(), false, false, $checkJumpPermissions);
}
if ($newNodePartials->hasInPartials()) {
$ainTags = $this->findInTags($db, $tableNodeRef, $pids, $newNodePartials->getInPartials(), false, false, $checkJumpPermissions);
}
if ($newNodePartials->hasMetaPartials()) {
$ameta = $this->NodeMetaDAO->findMeta($db, $tableNodeRef, $pids, $newNodePartials->getMetaPartials(), false);
}
foreach ($foundRows as $nodeRefString => &$nrow) {
$nrow->setNodePartials($newNodePartials);
$nrow->setMetas(isset($ameta[$nrow[$idField]]) ? $ameta[$nrow[$idField]] : array());
$nrow->setOutTags(isset($aoutTags[$nrow[$idField]]) ? $aoutTags[$nrow[$idField]] : array());
$nrow->setInTags(isset($ainTags[$nrow[$idField]]) ? $ainTags[$nrow[$idField]] : array());
}
$this->Benchmark->end('partial-jump');
}
$nodeRows = array_merge($nodeRows, $foundRows);
}
}
foreach ($newrows as $row) {
// $id = $row['ID'];
// unset($row['ID']);
// error_log(print_r($row, true));
if ($resolveLinkedRecords) {
$nodeRef = $row['TagLinkNodeRef'];
if (!array_key_exists((string) $nodeRef, $nodeRows)) {
continue;
}
$tagNode = $nodeRows[(string) $nodeRef];
// if need to filter out jump partials
if (array_key_exists($row['TagRole'], $jumpParams)) {
示例4: findAll
//.........这里部分代码省略.........
$batchLimit = $moreThan1Table ? $this->nodeDatabaseBatchLimit : $limit;
while ($batchOffset > -1) {
$rows = null;
$reorderOnce = false;
$q->LIMIT($moreThan1Table && $batchLimit > 1 ? $batchLimit + 1 : $batchLimit);
$q->OFFSET($batchOffset);
$s = (string) $q;
//$s = str_replace($firstTable, $table, $s);
//$s = str_replace($firstTableID, $tableid, $s);
$rows = $db->readAll($s);
if (empty($rows)) {
$batchOffset = -1;
break;
}
// $this->Benchmark->start('pushrows');
foreach ($rows as $k => $row) {
if ($batchLimit > 1 && $k > $batchLimit - 1) {
break;
}
$row['ElementID'] = $elementid;
// if there is no limit, push all rows
// if there is only 1 table to aggregate, push all rows
// if the index of the current result set is less than the total needed rows, push
if (is_null($limit) || !$moreThan1Table || $c < $limit + $offset) {
$row['NodeRef'] = new NodeRef($elements[$row['ElementID']], $row['Slug']);
$resultingRows[] = $row;
++$c;
} else {
if ($k >= $limit + $offset) {
// done with this table (element)
$batchOffset = -1;
break 2;
}
if (!$reorderOnce) {
$reorderOnce = true;
$resultingRows = $this->NodesHelper->sortNodes($resultingRows, $orderObjects);
}
$lastRow = $resultingRows[$c - 1];
// if this row is before the last row in the order, add it in
if (!$this->NodesHelper->compareNodes($lastRow, $row, $orderObjects)) {
$row['NodeRef'] = new NodeRef($elements[$row['ElementID']], $row['Slug']);
$resultingRows[] = $row;
//++$c;
$lastRow = null;
// else break, we're done with this table (element)
} else {
// error_log('stopped at last: '.$lastRow['Slug'].' '.$lastRow['ActiveDate']);
// error_log('stopped at: '.$row['Slug'].' '.$row['ActiveDate']);
$batchOffset = -1;
$lastRow = null;
break 2;
}
}
}
// $this->Benchmark->end('pushrows');
if (!$moreThan1Table && $offset == 0 || count($rows) < $batchLimit + 1) {
$batchOffset = -1;
} else {
$batchOffset = $batchOffset + $batchLimit;
}
}
$rows = null;
if ($qcount > 1 && $offset > 0 && $moreThan1Table && !empty($resultingRows)) {
// error_log('resorting');
// error_log('needed total: '.($limit+$offset));
$resultingRows = $this->NodesHelper->sortNodes($resultingRows, $orderObjects);
$resultingRows = $this->NodesHelper->sliceNodes($resultingRows, $limit + $offset, 0);
// $resultingRows = array_slice($resultingRows, 0, ($limit+$offset));
$c = count($resultingRows);
}
++$qcount;
$qArgs = null;
}
$queries = null;
if (!empty($resultingRows)) {
if ($offset == 0 && $moreThan1Table) {
$resultingRows = $this->NodesHelper->sortNodes($resultingRows, $orderObjects);
}
$resultingRows = $this->NodesHelper->sliceNodes($resultingRows, $limit, $offset, $moreThan1Table && $offset > 0);
}
}
if (!empty($resultingRows)) {
$resultingNodeRefs = ArrayUtils::arrayMultiColumn($resultingRows, 'NodeRef');
if ($nodeQuery->hasParameter('NodeRefs.only') && StringUtils::strToBool($nodeQuery->getParameter('NodeRefs.only')) == true) {
$nodeQuery->setResults($resultingNodeRefs);
} else {
$results = $this->NodeMultiGetDAO->multiGet($resultingNodeRefs, $nodePartials, $forceReadWrite, $checkPermissions, true);
$keys = array_map('strval', $resultingNodeRefs);
$results = ArrayUtils::arraySortUsingKeys($results, $keys);
$keys = null;
$resultingNodeRefs = null;
$nodeQuery->setResults($results);
}
}
if ($doCounts) {
$nodeQuery->setTotalRecords($totalCount);
}
$this->Benchmark->end('findall');
return $nodeQuery;
}