/** * @param string $script */ protected function addFindOne(&$script) { $className = $this->builder->getStubObjectBuilder()->getClassname(); $peerClassName = $this->builder->getStubPeerBuilder()->getClassname(); $script .= "\n/**\n * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria\n * and format the result with the current formatter\n * By default, returns a model object\n *\n * @param PropelPDO \$con an optional connection object\n *\n * @return mixed|{$className} the result, formatted by the current formatter\n */\npublic function findOne(\$con = null)\n{\n if (\$this->isCacheEnable() && \$cache = {$peerClassName}::cacheFetch(\$this->getCacheKey())) {\n if (\$cache instanceof {$className}) {\n return \$cache;\n }\n }\n\n if (\$con === null) {\n \$con = Propel::getConnection(\$this->getDbName(), Propel::CONNECTION_READ);\n }\n \$this->basePreSelect(\$con);\n \$criteria = \$this->isKeepQuery() ? clone \$this : \$this;\n \$criteria->limit(1);\n \$stmt = \$criteria->doSelect(\$con);\n\n \$data = \$criteria->getFormatter()->init(\$criteria)->formatOne(\$stmt);\n\n if (\$this->isCacheEnable()) {\n {$peerClassName}::cacheStore(\$this->getCacheKey(), \$data, \$this->getLifeTime());\n }\n\n return \$data;\n}\n "; }