Skip to content

Commit 86ec665

Browse files
author
TCB13
committed
Added QueryBuilder::toUnidimensionalArray()
1 parent 7a2712e commit 86ec665

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/QueryBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,13 @@ public function toObject($className = \stdClass::class, bool $fullObject = false
602602
return $this->deserializeResult($className, $className, $className);
603603
}
604604

605+
public function toUnidimensionalArray(string $key, bool $unique = false)
606+
{
607+
$arr = array_column($this->toArray(), $key);
608+
609+
return $unique ? array_unique($arr) : $arr;
610+
}
611+
605612
public function toJson(): string
606613
{
607614
return json_encode($this->toArray());

0 commit comments

Comments
 (0)