mirror of
https://codeberg.org/vlw/scaffold.git
synced 2025-11-05 06:02:42 +01:00
Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fa45083d0 | |||
| 00337cd3aa |
2 changed files with 36 additions and 32 deletions
|
|
@ -72,9 +72,8 @@
|
|||
*
|
||||
* @return bool Entity exists
|
||||
*/
|
||||
public bool $isset {
|
||||
// Returns bool if row is set or attempts to resolve and set if null
|
||||
get => $this->_isset ??= new Database()
|
||||
public function isset(): bool {
|
||||
return $this->_isset ??= new Database()
|
||||
->from($this->table)
|
||||
->where($this->where)
|
||||
->limit(1)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
namespace vlw\Scaffold\Helpers;
|
||||
|
||||
const UUID_LENGTH = 36;
|
||||
/**
|
||||
* Generate Universally unique identifiers
|
||||
*/
|
||||
class UUID {
|
||||
public const LENGTH = 36;
|
||||
|
||||
/**
|
||||
* Generate an all binary 0:s UUID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function uuid_nil(): string {
|
||||
public static function nil(): string {
|
||||
return "00000000-0000-0000-0000-000000000000";
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +22,7 @@
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function uuid_max(): string {
|
||||
public static function max(): string {
|
||||
return "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +31,7 @@
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function uuid_v4(): string {
|
||||
public static function v4(): string {
|
||||
return sprintf("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
||||
mt_rand(0, 0xffff),
|
||||
|
|
@ -36,3 +40,4 @@
|
|||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue