Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #483 from brunnels/master

Fix for one-to-one related object have unnecessary queries during hydration
  • Loading branch information...
commit e9ef7b1111163806193b55a7af40477d44b2b519 2 parents fc58262 + 6be009c
William Durand willdurand authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 generator/lib/builder/om/PHP5ObjectBuilder.php
7 generator/lib/builder/om/PHP5ObjectBuilder.php
View
@@ -3261,13 +3261,14 @@ protected function addFKAccessor(&$script, ForeignKey $fk)
* Get the associated $className object
*
* @param PropelPDO \$con Optional Connection object.
+ * @param \$doQuery Executes a query to get the object if required
* @return $className The associated $className object.
* @throws PropelException
*/
- public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO \$con = null)
+ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PropelPDO \$con = null, \$doQuery = true)
{";
$script .= "
- if (\$this->$varName === null && ($conditional)) {";
+ if (\$this->$varName === null && ($conditional) && \$doQuery) {";
if ($useRetrieveByPk) {
$script .= "
\$this->$varName = ".$fkQueryBuilder->getClassname()."::create()->findPk($localColumns, \$con);";
@@ -3971,7 +3972,7 @@ public function set".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($cla
\$this->$varName = \$v;
// Make sure that that the passed-in $className isn't already associated with this object
- if (\$v !== null && \$v->get".$this->getFKPhpNameAffix($refFK, $plural = false)."() === null) {
+ if (\$v !== null && \$v->get".$this->getFKPhpNameAffix($refFK, $plural = false)."(null, false) === null) {
\$v->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this);
}
Please sign in to comment.
Something went wrong with that request. Please try again.