如何在查找时从关联模型中选择字段

时间:2015-06-11 22:31:56

标签: cakephp-3.0

在我这之前:

//ArticlesController::index
$articles = $this->Articles->find('all', [
  'contain' => ['Comments']
]);

所以我设置了fields key

//ArticlesController::index
$articles = $this->Articles->find('all', [
  'fields' => ['title', 'text],
  'contain' => ['Comments']
]);

由于我设置了fields keyfind的结果不再带来comments

1 个答案:

答案 0 :(得分:1)

/**
 * Enqueue Scripts with CF7 Dependencies
 */
function so30727367_enqueue_scripts() {
    wp_enqueue_script( 'stackoverflow-scripts', plugin_dir_url(__FILE__) . 'scripts.js', array('jquery'), null, true );
}
add_action( 'wpcf7_enqueue_scripts', 'so30727367_enqueue_scripts' );