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