示例#1
0
 public function execute()
 {
     $entity = new Entity();
     $entity->setRepository(context()->get($this->migration->getRepository()));
     $cache = $entity->getRepository()->getCache();
     foreach ($this->migration->getTables() as $table) {
         $this->sql = [];
         if ($cache->hasTable($table->getName())) {
             $this->updateTable($cache, $table);
         } else {
             $this->installTable($cache, $table);
         }
     }
     if ($this->sqls) {
         $this->applyMigration();
     }
 }
示例#2
0
 public function getRightRecord(Entity $rightEntity, $foreignKey, $primaryValue)
 {
     if (!$primaryValue) {
         return null;
     }
     $rightEntity->setRepository($this->getLeftEntity()->getRepository());
     $entity = $rightEntity->where($foreignKey, $primaryValue);
     /**
      * Add conditions applied on query.
      */
     foreach ($this->getQuery()->getWhere()->getChildren() as $condition) {
         $entity->where(function (Parenthesis $parenthesis) use($condition) {
             $parenthesis->push($condition);
         });
     }
     foreach ($this->getQuery()->getBinds('where') as $bind) {
         $entity->getQuery()->bind($bind, 'where');
     }
     return (new GetRecords($entity))->executeOne();
 }