25 lines
612 B
PHP
25 lines
612 B
PHP
<?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})));
|
|
}
|
|
|
|
}
|