Major upgrade #3
@ -15,6 +15,8 @@ class Load << (F,LightGreen) >> #Green {
|
||||
+ items(array $select, array $tables, ...) : ?array
|
||||
+ row(array $select, array $tables, ...) : ?array
|
||||
+ item(array $select, array $tables, ...) : ?object
|
||||
+ max(string $field, array $tables, ...) : ?int
|
||||
+ count(array $tables, array $filter) : ?int
|
||||
+ value(array $select, array $tables, ...) : mixed
|
||||
# many(array $select, array $tables, ...) : bool
|
||||
# one(array $select, array $tables, ...) : bool
|
||||
@ -75,6 +77,25 @@ note left of Load::item
|
||||
?array $order = null
|
||||
end note
|
||||
|
||||
note right of Load::max
|
||||
Get the max value based on a filtered result from a given table
|
||||
|
||||
since: 3.2.0
|
||||
return: ?int
|
||||
|
||||
arguments:
|
||||
string $field
|
||||
array $tables
|
||||
array $filter
|
||||
end note
|
||||
|
||||
note left of Load::count
|
||||
Count the number of items based on filter result from a given table
|
||||
|
||||
since: 3.2.0
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note right of Load::value
|
||||
Load one value from a row
|
||||
|
||||
|
@ -144,6 +144,71 @@ final class Load extends Database implements LoadInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value based on a filtered result from a given table
|
||||
*
|
||||
* @param string $field The field key
|
||||
* @param string $tables The tables
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function max($field, array $tables, array $filter): ?int
|
||||
{
|
||||
// only do check if we have the table set
|
||||
if (isset($tables['a']))
|
||||
{
|
||||
// get the query
|
||||
$query = $this->query(["all" => "MAX(`$field`)"], $tables, $filter);
|
||||
|
||||
// Load the max number
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// check if we have values
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
}
|
||||
|
||||
// data does not exist
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of items based on filter result from a given table
|
||||
*
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function count(array $tables, array $filter): ?int
|
||||
{
|
||||
// only do check if we have the table set
|
||||
if (isset($tables['a']))
|
||||
{
|
||||
// get the query
|
||||
$query = $this->query(["all" => 'COUNT(*)'], $tables, $filter);
|
||||
|
||||
// Load the max number
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// check if we have values
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
}
|
||||
|
||||
// data does not exist
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load one value from a row
|
||||
*
|
||||
|
@ -118,6 +118,71 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max value based on a filtered result from a given table
|
||||
*
|
||||
* @param string $field The field key
|
||||
* @param string $tables The tables
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function max($field, array $tables, array $filter): ?int
|
||||
{
|
||||
// only do check if we have the table set
|
||||
if (isset($tables['a']))
|
||||
{
|
||||
// get the query
|
||||
$query = $this->query(["all" => "MAX(`$field`)"], $tables, $filter);
|
||||
|
||||
// Load the max number
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// check if we have values
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
}
|
||||
|
||||
// data does not exist
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of items based on filter result from a given table
|
||||
*
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function count(array $tables, array $filter): ?int
|
||||
{
|
||||
// only do check if we have the table set
|
||||
if (isset($tables['a']))
|
||||
{
|
||||
// get the query
|
||||
$query = $this->query(["all" => 'COUNT(*)'], $tables, $filter);
|
||||
|
||||
// Load the max number
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// check if we have values
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
}
|
||||
|
||||
// data does not exist
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load one value from a row
|
||||
*
|
||||
|
@ -15,6 +15,8 @@ interface LoadInterface #Lavender {
|
||||
+ items(array $select, array $tables, ...) : ?array
|
||||
+ row(array $select, array $tables, ...) : ?array
|
||||
+ item(array $select, array $tables, ...) : ?object
|
||||
+ max(string $field, array $tables, ...) : ?int
|
||||
+ count(array $tables, array $filter) : ?int
|
||||
+ value(array $select, array $tables, ...) : mixed
|
||||
}
|
||||
|
||||
@ -72,6 +74,25 @@ note right of LoadInterface::item
|
||||
?array $order = null
|
||||
end note
|
||||
|
||||
note right of LoadInterface::max
|
||||
Get the max value based on a filtered result from a given table
|
||||
|
||||
since: 3.2.0
|
||||
return: ?int
|
||||
|
||||
arguments:
|
||||
string $field
|
||||
array $tables
|
||||
array $filter
|
||||
end note
|
||||
|
||||
note right of LoadInterface::count
|
||||
Count the number of items based on filter result from a given table
|
||||
|
||||
since: 3.2.0
|
||||
return: ?int
|
||||
end note
|
||||
|
||||
note right of LoadInterface::value
|
||||
Load one value from a row
|
||||
|
||||
|
@ -75,6 +75,29 @@ interface LoadInterface
|
||||
**/
|
||||
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object;
|
||||
|
||||
/**
|
||||
* Get the max value based on a filtered result from a given table
|
||||
*
|
||||
* @param string $field The field key
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function max($field, array $tables, array $filter): ?int;
|
||||
|
||||
/**
|
||||
* Count the number of items based on filter result from a given table
|
||||
*
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function count(array $tables, array $filter): ?int;
|
||||
|
||||
/**
|
||||
* Load one value from a row
|
||||
*
|
||||
@ -86,7 +109,6 @@ interface LoadInterface
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
|
||||
|
||||
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,29 @@
|
||||
**/
|
||||
public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object;
|
||||
|
||||
/**
|
||||
* Get the max value based on a filtered result from a given table
|
||||
*
|
||||
* @param string $field The field key
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function max($field, array $tables, array $filter): ?int;
|
||||
|
||||
/**
|
||||
* Count the number of items based on filter result from a given table
|
||||
*
|
||||
* @param string $tables The table
|
||||
* @param array $filter The filter keys
|
||||
*
|
||||
* @return int|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function count(array $tables, array $filter): ?int;
|
||||
|
||||
/**
|
||||
* Load one value from a row
|
||||
*
|
||||
@ -65,4 +88,4 @@
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
|
||||
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
|
Loading…
Reference in New Issue
Block a user