find(list)返回几个空白选项,find(all)返回正确的数据,但格式为{

时间:2016-07-21 21:48:09

标签: cakephp-3.0

AvadiariesTable.php

Inner

AlumnesGrupsTable.php

$this->belongsTo('AlumnesGrups', [
        'foreignKey' => 'alumnes_grup_id',
        'joinType' => 'INNER'

为什么这是AvadiariesController.php:

$this->belongsTo('Alumnes', [
        'foreignKey' => 'alumne_id',
        'joinType' => 'INNER'
    ]);
    $this->belongsTo('Grups', [
        'foreignKey' => 'grup_id',
        'joinType' => 'INNER'
    ]);

返回正确的数据,但格式如下:

{“Alumnes”:{“name”:“Angela Smith”}}?

我怎样才能得到安吉拉史密斯?如果我将find(all)更改为find(list),则选择框将填充多个空白选项。

谢谢!

1 个答案:

答案 0 :(得分:0)

使用valueField并使用keyField表示您要显示的字段,并使用$alumnesGrups = $this->Avadiaries->AlumnesGrups->find('list', [ 'keyField' => 'alumne.name', 'valueField' => 'alumne.name']) ->contain(['Alumnes', 'Grups']) ->where(['Grups.id =' => 1]) ->order(['Alumnes.name' => 'ASC']); 表示其值:

- (void)videoOutputOverlay {

  movieFile = [[GPUImageMovie alloc] initWithURL:self.post.videoUrl];
  movieFile.runBenchmark = YES;
  movieFile.playAtActualSpeed = NO;

  filter = [[GPUImageBrightnessFilter alloc] init];
  //  [filter useNextFrameForImageCapture];
  [(GPUImageBrightnessFilter *)filter setBrightness:0.0];
  [filter setInputRotation:kGPUImageRotateRight atIndex:0];

  GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
  //  [blendFilter useNextFrameForImageCapture];
  blendFilter.mix = 1.0;

  UIView *contentView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  [contentView addSubview:self.drawingView];
  [contentView addSubview:self.textOverlayView];
  uiElementInput = [[GPUImageUIElement alloc] initWithView:contentView];

  [movieFile addTarget:filter];
  [filter addTarget:blendFilter];
  [uiElementInput addTarget:blendFilter];

  // In addition to displaying to the screen, write out a processed version of the movie to disk
  NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
  unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie

  //load asset to grab size
  AVAsset *asset = [AVAsset assetWithURL:self.post.videoUrl];

  AVAssetTrack *track = asset.tracks.firstObject;
  CGSize exportSize = CGSizeMake(track.naturalSize.height, track.naturalSize.width);

  movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:[NSURL fileURLWithPath:pathToMovie] size:exportSize];
  [blendFilter addTarget:movieWriter];

  __weak GPUImageUIElement *weakUIElement = uiElementInput;
  [filter setFrameProcessingCompletionBlock:^(GPUImageOutput *filter, CMTime frameTime) {
    [weakUIElement update];
  }];

  // Configure this for video from the movie file, where we want to preserve all video frames and audio samples
  movieWriter.shouldPassthroughAudio = YES;
  movieFile.audioEncodingTarget = movieWriter;
  [movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

  [movieWriter startRecording];
  [movieFile startProcessing];

  __weak PostPreviewViewController *weakSelf = self;
  [movieWriter setCompletionBlock:^{
    UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, weakSelf, @selector(image:completedSavingLocallyWithError:usingContextInfo:), NULL);
  }];
}

检查: http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#finding-key-value-pairs