/framework/core/db/DbRelationshipHasOne.php
http://zoop.googlecode.com/ · PHP · 22 lines · 19 code · 3 blank · 0 comment · 2 complexity · bfae1d597824648c2fbec1d222e26d2c MD5 · raw file
- <?php
- class DbRelationshipHasOne extends DbRelationshipBasic
- {
- private $theOne;
- private $theOneIsSet;
-
- public function getInfo()
- {
- if(!$this->theOneIsSet)
- {
- $remoteTableName = DbObject::_getTableName($this->remoteClassName);
- $sql = "select * from $remoteTableName where {$this->remoteFieldName} = :id:int";
- $row = SqlFetchRow($sql, array('id' => $this->dbObject->getField($this->localFieldName)));
- if($row)
- $this->theOne = new $this->remoteClassName($row);
-
- $this->theOneIsSet = 1;
- }
-
- return $this->theOne;
- }
- }