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


PHP Migration::getRemoteModel方法代码示例

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


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

示例1: processDeletions

 function processDeletions()
 {
     // debug($this->options);
     $ids = $this->LocalModel->migrationDeletedIds($this->Process->targetInstance);
     if (!empty($ids)) {
         if (!empty($this->options['instance']['execeptions']) || !empty($this->options['execeptions']) && $this->options['mode'] != 'exclude') {
             if ($this->options['mode'] == 'exclude') {
                 $ids = array_diff($ids, $this->options['instance']['execeptions']);
             } else {
                 $ids = array_intersect($ids, $this->options['instance']['execeptions']);
             }
         }
         if (!empty($ids)) {
             $remoteModel = Migration::getRemoteModel($this->LocalModel, $this->Process->targetInstance);
             $dry = MigrationConfig::load('dryRun');
             if ($dry) {
                 $this->msg('Delete attempt on ' . $remoteModel->alias . ' for Ids : ' . implode(', ', $ids));
             } else {
                 if ($remoteModel->deleteAll(array($remoteModel->alias . '.' . $remoteModel->primaryKey => $ids))) {
                     $this->msg(str_replace('%nb%', count($ids), __('%nb% entries deleted on the remote server', true)));
                     $this->MigrationRemote->deleteAll(array('model' => $this->LocalModel->getFullName(), 'remote_id' => $ids));
                 }
             }
         }
     }
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:26,代码来源:migration_batch.php

示例2: getRemoteId

 function getRemoteId($Model, $localEntry, $targetInstance)
 {
     $MR = $this->MigrationRemote;
     $fullName = $this->getFullName($Model);
     $settings = $this->settings[$Model->alias];
     if (is_numeric($localEntry)) {
         $local_id = $localEntry;
     } else {
         $local_id = $localEntry[$Model->alias][$Model->primaryKey];
     }
     $remoteNode = $MR->find('first', array('conditions' => array($MR->alias . '.model' => $fullName, $MR->alias . '.instance' => $targetInstance, $MR->alias . '.local_id' => $local_id)));
     if ($remoteNode) {
         return $remoteNode[$MR->alias]['remote_id'];
     }
     if (!empty($settings['mapFields'])) {
         $remoteModel = Migration::getRemoteModel($Model, $targetInstance);
         $MapFieldsConds = $this->_remoteEntryMapFieldsConds($Model, $localEntry, $remoteModel);
         if ($MapFieldsConds) {
             $remote = $remoteModel->find('first', array('fields' => array($remoteModel->primaryKey), 'conditions' => $MapFieldsConds, 'recursive' => -1));
             return $remote[$remoteModel->alias][$remoteModel->primaryKey];
         }
     }
     $lastSync = $this->getLastSync($Model, $targetInstance);
     if (!empty($lastSync)) {
         if (is_numeric($localEntry)) {
             $localEntry = $Model->find('first', array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $localEntry)));
         }
         if (strtotime($localEntry[$Model->alias]['modified']) <= $lastSync) {
             return $local_id;
         }
     }
     return null;
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:33,代码来源:migration.php

示例3: getEntriesStates

 function getEntriesStates($Model, $entries, $instance = null)
 {
     $ids = array();
     if (empty($instance)) {
         $alias = $Model->alias;
     } else {
         $remoteModel = Migration::getRemoteModel($Model, $instance);
         $alias = $remoteModel->alias;
     }
     foreach ($entries as $entry) {
         $ids[] = $entry[$alias][$Model->primaryKey];
     }
     return $this->getIdsStates($Model->alias, $ids);
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:14,代码来源:migrated.php

示例4: getRemoteModel

 function getRemoteModel()
 {
     if (isset($this->_remoteModel)) {
         return $this->_remoteModel;
     }
     return $this->_remoteModel = Migration::getRemoteModel($this->LocalModel, $this->targetInstance);
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:7,代码来源:entry_sync.php

示例5: admin_deleted

 function admin_deleted($instance, $modelName, $id)
 {
     App::import('Lib', 'Migration.Migration');
     $Model = Migration::getLocalModel($modelName);
     $remoteModel = Migration::getRemoteModel($Model, $instance);
     $remote = $remoteModel->read(null, $id);
     $this->set('modelUrlAlias', $Model->getUrlName());
     $this->set('modelAlias', $remoteModel->alias);
     $this->set('remote', $remote);
 }
开发者ID:kevthunder,项目名称:cake-migration,代码行数:10,代码来源:migration_nodes_controller.php


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