Skip to content

Commit 25efc00

Browse files
committed
feat: min, max aggregate func
1 parent 70512de commit 25efc00

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"editor.defaultFormatter": "esbenp.prettier-vscode",
1111
"editor.formatOnSave": true,
1212
"editor.codeActionsOnSave": {
13-
"source.fixAll.eslint": true
13+
"source.fixAll.eslint": "explicit"
1414
},
1515
"stylelint.snippet": ["css", "scss"],
1616
"stylelint.validate": ["css", "scss", "postcss"],

src/QueryBuilder.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,26 @@ public function count()
904904
return \is_array($result) && !empty($result[0]->count) ? $result[0]->count : null;
905905
}
906906

907+
public function max($column)
908+
{
909+
$this->select = ['MAX(' . $column . ') as max'];
910+
$this->_method = 'Select';
911+
$result = $this->exec();
912+
unset($this->select);
913+
914+
return \is_array($result) && !empty($result[0]->max) ? $result[0]->max : null;
915+
}
916+
917+
public function min($column)
918+
{
919+
$this->select = ['MIN(' . $column . ') as min'];
920+
$this->_method = 'Select';
921+
$result = $this->exec();
922+
unset($this->select);
923+
924+
return \is_array($result) && !empty($result[0]->min) ? $result[0]->min : null;
925+
}
926+
907927
public function delete()
908928
{
909929
$this->_method = self::DELETE;

0 commit comments

Comments
 (0)