PageRenderTime 13ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/core/db/DbRelationshipHasOne.php

http://zoop.googlecode.com/
PHP | 22 lines | 19 code | 3 blank | 0 comment | 2 complexity | bfae1d597824648c2fbec1d222e26d2c MD5 | raw file
 1<?php
 2class DbRelationshipHasOne extends DbRelationshipBasic
 3{
 4	private $theOne;
 5	private $theOneIsSet;
 6	
 7	public function getInfo()
 8	{
 9		if(!$this->theOneIsSet)
10		{
11			$remoteTableName = DbObject::_getTableName($this->remoteClassName);
12			$sql = "select * from $remoteTableName where {$this->remoteFieldName} = :id:int";
13			$row = SqlFetchRow($sql, array('id' => $this->dbObject->getField($this->localFieldName)));
14			if($row)
15				$this->theOne = new $this->remoteClassName($row);
16			
17			$this->theOneIsSet = 1;
18		}
19			
20		return $this->theOne;
21	}
22}