src/SnooPHP/Model/Model.php
public function has($forClass, $forColumn = null)
	{
		$refTable = static::tableName();
		$forTable = $forClass::tableName();
		$refColumn = static::$idColumn;
		$forColumn = $forColumn ?: strtolower(static::modelName())."_id";

		$rows = Db::query("
			select F.*
			from $refTable as R, $forTable as F
			where R.$refColumn = F.$forColumn and R.$refColumn = :id
		", ["id" => $this->$refColumn], static::getDbName());

		if ($rows === false)
			return false;
		if (empty($rows))
			return null;
		
		// Populate model
		$forModel = new $forClass;
		foreach ($rows[0] as $col => $val) $forModel->$col = $forModel->decodeValue($val, $col);
		return $forModel;
	}
public function has($forClass, $forColumn = null)
	{
		$refTable = static::tableName();
		$forTable = $forClass::tableName();
		$refColumn = static::$idColumn;
		$forColumn = $forColumn ?: strtolower(static::modelName())."_id";

		$rows = Db::query("
			select F.*
			from $refTable as R, $forTable as F
			where R.$refColumn = F.$forColumn and R.$refColumn = :id
		", ["id" => $this->$refColumn], static::getDbName());

		if ($rows === false)
			return false;
		if (empty($rows))
			return null;
		
		// Populate model
		$forModel = new $forClass;
		foreach ($rows[0] as $col => $val) $forModel->$col = $forModel->decodeValue($val, $col);
		return $forModel;
	}
One-to-one relationship

@param string	$forClass	foreign model class name
@param string	$forColumn	foreign column if it differs from className_id (ex. user_id)

@return Model|bool foreign model or false if fails