Creating relations abstract classes

This commit is contained in:
ahwelp
2022-03-23 22:01:08 +00:00
parent f5c2a9b6f4
commit ec52a9b573
5 changed files with 169 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace ORM;
class BelongsTo {
private $foreignObject;
private $localField;
private $remoteField;
private $localElement;
function __construct($foreignObject, $localField, $remoteField = 'id', $localElement) {
$this->foreignObject = $foreignObject;
$this->localField = $localField;
$this->remoteField = $remoteField;
$this->localElement = $localElement;
}
function get() {
return $this->foreignObject::findOne(Array($this->remoteField => Array('=', $this->localElement->{$this->localField})));
}
}