$sub_query = TableRegistry::get("Test2")->find();
$sub_query->select(["count" => "SUM(Test2.score)"])
->where(["Test2.ref = Test1.id"]);
$query = TableRegistry::get("Test1")->find("All");
$query->select([
"Test1.id", "Test1.name", "Test1.roll",
"score" => $sub_query
]);
$list = $query->all()->toArray();
$sub_query->select(["count" => "SUM(Test2.score)"])
->where(["Test2.ref = Test1.id"]);
$query = TableRegistry::get("Test1")->find("All");
$query->select([
"Test1.id", "Test1.name", "Test1.roll",
"score" => $sub_query
]);
$list = $query->all()->toArray();
No comments:
Post a Comment