当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::targetList方法代码示例

本文整理汇总了PHP中Migration::targetList方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::targetList方法的具体用法?PHP Migration::targetList怎么用?PHP Migration::targetList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migration的用法示例。


在下文中一共展示了Migration::targetList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: admin_diff

 function admin_diff($modelName, $id)
 {
     App::import('Lib', 'Migration.Migration');
     $modelName = Migration::urlParamToModelName($modelName);
     $Model = Migration::getLocalModel($modelName);
     $this->loadModel($modelName);
     $Model->joinMigrationRemote();
     $local = $Model->read(null, $id);
     $targets = Migration::targetList();
     $remotes = array();
     foreach ($targets as $key => $label) {
         $remoteModel = Migration::getRemoteModel($Model, $key);
         $remotes[$key] = $Model->getRemoteEntry($local, $key);
         $remotes[$key]['alias'] = $remoteModel->alias;
     }
     $local = $Model->getRawEntry($local);
     $this->set('localId', $id);
     $this->set('local', $local);
     $this->set('modelAlias', $Model->alias);
     $this->set('modelUrlAlias', $Model->getUrlName());
     $this->set('remotes', $remotes);
     $this->set('targets', $targets);
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:23,代码来源:migration_nodes_controller.php

示例2: migrationDeletedIds

 function migrationDeletedIds($Model, $targetInstance = null)
 {
     $MR = $this->MigrationRemote;
     $MN = $this->MigrationNode;
     $fullName = $this->getFullName($Model);
     $deletedIds = $this->MigrationRemote->find('list', array('fields' => array($MR->alias . '.remote_id', $MR->alias . '.remote_id', $MR->alias . '.instance'), 'conditions' => array($MR->alias . '.model' => $fullName, $Model->alias . '.' . $Model->primaryKey => null), 'joins' => array(array('alias' => $Model->alias, 'table' => $Model->useTable, 'type' => 'LEFT', 'conditions' => array($MR->alias . '.local_id = ' . $Model->alias . '.' . $Model->primaryKey)))));
     if ($targetInstance) {
         $targets = array($targetInstance => $targetInstance);
     } else {
         $targets = Migration::targetList();
     }
     $format = $Model->getDataSource()->columns['datetime']['format'];
     foreach ($targets as $instance => $name) {
         $lastSync = $this->getLastSync($Model, $instance);
         $existingLocalCond = $this->FindPresyncConds($Model, array('conditions' => array('created <= ' => date($format, $lastSync))));
         $remoteModel = Migration::getRemoteModel($Model, $instance);
         $ids = $remoteModel->find('list', array('fields' => array($Model->primaryKey, $Model->primaryKey), 'conditions' => array('created <= ' => date($format, $lastSync), 'not' => array($existingLocalCond))));
         if (!empty($ids)) {
             $deletedIds[$instance] = array_merge(empty($deletedIds[$instance]) ? array() : $deletedIds[$instance], $ids);
         }
         // debug($remoteOnly);
     }
     if (!empty($targetInstance) && !is_array($targetInstance)) {
         $deletedIds = empty($deletedIds[$targetInstance]) ? array() : $deletedIds[$targetInstance];
     }
     return $deletedIds;
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:27,代码来源:migration.php

示例3: admin_index

 function admin_index()
 {
     App::import('Lib', 'Migration.Migration');
     App::import('Lib', 'Migration.MigrationProcess');
     $targets = Migration::targetList();
     if (empty($targets)) {
         $this->render('admin_missing_target');
         return;
     }
     //$Model = Migration::getLocalModel('Slider');
     //debug($Model->migrationDeletedCount());
     // $Model = Migration::getLocalModel('Page');
     // debug($Model->migrationDeletedCount());
     $posted = !empty($this->data);
     if ($posted) {
         foreach ($this->data['Migration']['targets'] as $target => $active) {
             if ($active) {
                 $process = new MigrationProcess($target);
                 foreach ($this->data['Migration']['models'] as $modelName => $active) {
                     if ($active) {
                         $modelName = str_replace('-', '.', $modelName);
                         //$process->models[$modelName] = $this->Migrated->findOpt($modelName);
                         $process->setModelOpt($modelName, $this->Migrated->getModelOpt($modelName));
                     }
                 }
                 // debug($process->models);
                 $process->run();
                 $this->Session->setFlash(implode("<br>\n", $process->msgs));
             }
         }
         $dry = MigrationConfig::load('dryRun');
         if ($dry) {
             $this->data = array();
             $posted = false;
         } else {
             $this->Migrated->clear();
             $this->redirect(array('action' => 'index'));
         }
     }
     $modelsNames = Migration::migratingModels();
     $models = array();
     $pendings = Migration::pendingList();
     foreach ($modelsNames as $mname) {
         $m = array('class' => Migration::classNameParts($mname, 'class'), 'name' => str_replace('.', '-', $mname), 'count' => 0, 'deleted_count' => 0, 'migrated_count' => 0, 'param' => Migration::modelNameToUrl($mname));
         if (!empty($pendings[$mname])) {
             $m['count'] = array_sum($pendings[$mname]);
             $m['deleted_count'] = empty($pendings[$mname]['delete']) ? 0 : $pendings[$mname]['delete'];
             $m['migrated_count'] = $this->Migrated->alterCount($mname, $m['count']);
             if (!$posted) {
                 $this->data['Migration']['models'][$m['name']] = 1;
             }
         }
         $models[] = $m;
     }
     // debug($models);
     if (!$posted) {
         foreach ($targets as $key => $label) {
             $this->data['Migration']['targets'][$key] = 1;
         }
     }
     $this->set('models', $models);
     $this->set('targets', $targets);
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:63,代码来源:migration_controller.php


注:本文中的Migration::targetList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。