Compare commits

..

No commits in common. "master" and "1.3.0" have entirely different histories.

2 changed files with 39 additions and 45 deletions

View file

@ -55,7 +55,7 @@
$this->_resolved = true; $this->_resolved = true;
$this->_row = $this->db $this->_row = $this->db
->from($this->table) ->for($this->table)
->where($this->where) ->where($this->where)
->limit(1) ->limit(1)
->select($this->columns) ->select($this->columns)
@ -72,9 +72,10 @@
* *
* @return bool Entity exists * @return bool Entity exists
*/ */
public function isset(): bool { public bool $isset {
return $this->_isset ??= new Database() // Returns bool if row is set or attempts to resolve and set if null
->from($this->table) get => $this->_isset ??= new Database()
->for($this->table)
->where($this->where) ->where($this->where)
->limit(1) ->limit(1)
->select() ->select()
@ -102,7 +103,7 @@
$this->_row[$key] = $value; $this->_row[$key] = $value;
return $this->db return $this->db
->from($this->table) ->for($this->table)
->where($this->where) ->where($this->where)
->update([$key => $value]); ->update([$key => $value]);
} }

View file

@ -2,18 +2,12 @@
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
*/ */
public static function nil(): string { function uuid_nil(): string {
return "00000000-0000-0000-0000-000000000000"; return "00000000-0000-0000-0000-000000000000";
} }
@ -22,7 +16,7 @@
* *
* @return string * @return string
*/ */
public static function max(): string { function uuid_max(): string {
return "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"; return "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
} }
@ -31,7 +25,7 @@
* *
* @return string * @return string
*/ */
public static function v4(): string { function uuid_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),
@ -40,4 +34,3 @@
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
); );
} }
}