dbAll() support distinct
This commit is contained in:
parent
aeaf3eb1dd
commit
1f14faf08c
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nulib\db;
|
namespace nulib\db;
|
||||||
|
|
||||||
|
use nulib\A;
|
||||||
use nulib\cl;
|
use nulib\cl;
|
||||||
use nulib\php\func;
|
use nulib\php\func;
|
||||||
use nulib\ValueException;
|
use nulib\ValueException;
|
||||||
@ -184,15 +185,19 @@ class Capacitor implements ITransactor {
|
|||||||
|
|
||||||
function dbAll(array $query, ?array $params=null): iterable {
|
function dbAll(array $query, ?array $params=null): iterable {
|
||||||
$primaryKeys = $this->channel->getPrimaryKeys();
|
$primaryKeys = $this->channel->getPrimaryKeys();
|
||||||
|
$select = "select";
|
||||||
|
if (A::pop($params, "distinct")) $select .= " distinct";
|
||||||
return $this->storage->db()->all(cl::merge([
|
return $this->storage->db()->all(cl::merge([
|
||||||
"select",
|
$select,
|
||||||
"from" => $this->getTableName(),
|
"from" => $this->getTableName(),
|
||||||
], $query), $params, $primaryKeys);
|
], $query), $params, $primaryKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbOne(array $query, ?array $params=null): ?array {
|
function dbOne(array $query, ?array $params=null): ?array {
|
||||||
|
$select = "select";
|
||||||
|
if (A::pop($params, "distinct")) $select .= " distinct";
|
||||||
return $this->storage->db()->one(cl::merge([
|
return $this->storage->db()->one(cl::merge([
|
||||||
"select",
|
$select,
|
||||||
"from" => $this->getTableName(),
|
"from" => $this->getTableName(),
|
||||||
], $query), $params);
|
], $query), $params);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user