Last active
October 23, 2015 07:05
Haydnで結果に含めるかどうかを行ごとにオンデマンドで判定する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vendor/ | |
composer.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hidenorigoto/haydn-select-returnnull", | |
"authors": [ | |
{ | |
"name": "hidenorigoto", | |
"email": "[email protected]" | |
} | |
], | |
"require": { | |
"quartet/haydn": "^1.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__.'/vendor/autoload.php'; | |
$data = [ | |
['name' => 'りんご', 'available' => true], | |
['name' => 'バナナ', 'available' => false], | |
['name' => 'みかん', 'available' => true], | |
]; | |
$set = new \Quartet\Haydn\Set(new \Quartet\Haydn\IO\Source\ArraySource('fruit', $data, new \Quartet\Haydn\IO\ColumnMapper\HashKeyColumnMapper())); | |
$set = new \Quartet\Haydn\Set\GroupingSet($set, | |
null, | |
function($row) { | |
return $row['available'] ? | |
new \Quartet\Haydn\Set(new \Quartet\Haydn\IO\Source\SingleRowSource('fruit', $row)) : | |
new \Quartet\Haydn\Set\EmptySet(); | |
}, | |
null | |
); | |
$result = $set->toArray(); | |
var_dump($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment