当前位置: 首页>>代码示例>>PHP>>正文


PHP OMBuilder::getNewObjectBuilder方法代码示例

本文整理汇总了PHP中OMBuilder::getNewObjectBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP OMBuilder::getNewObjectBuilder方法的具体用法?PHP OMBuilder::getNewObjectBuilder怎么用?PHP OMBuilder::getNewObjectBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OMBuilder的用法示例。


在下文中一共展示了OMBuilder::getNewObjectBuilder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addDoSelectWithI18n

 protected function addDoSelectWithI18n(&$script)
 {
     $table = $this->getTable();
     $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
     $className = $table->getPhpName();
     $pks = $table->getPrimaryKey();
     $pk = PeerBuilder::getColumnName($pks[0], $className);
     // get i18n table name and culture column name
     foreach ($table->getReferrers() as $fk) {
         $tblFK = $fk->getTable();
         if ($tblFK->getName() == $table->getAttribute('i18nTable')) {
             $i18nClassName = $tblFK->getPhpName();
             // FIXME
             $i18nPeerClassName = $i18nClassName . 'Peer';
             $i18nTable = $table->getDatabase()->getTable($tblFK->getName());
             $i18nTableObjectBuilder = OMBuilder::getNewObjectBuilder($i18nTable);
             $i18nTablePeerBuilder = OMBuilder::getNewPeerBuilder($i18nTable);
             $i18nPks = $i18nTable->getPrimaryKey();
             $i18nPk = PeerBuilder::getColumnName($i18nPks[0], $i18nClassName);
             $culturePhpName = '';
             $cultureColumnName = '';
             foreach ($tblFK->getColumns() as $col) {
                 if ("true" === strtolower($col->getAttribute('isCulture'))) {
                     $culturePhpName = $col->getPhpName();
                     $cultureColumnName = PeerBuilder::getColumnName($col, $i18nClassName);
                 }
             }
         }
     }
     $script .= "\n\n  /**\n   * Selects a collection of {$className} objects pre-filled with their i18n objects.\n   *\n   * @return array Array of {$className} objects.\n   * @throws PropelException Any exceptions caught during processing will be\n   *     rethrown wrapped into a PropelException.\n   */\n  public static function doSelectWithI18n(Criteria \$c, \$culture = null, \$con = null)\n  {\n    if (\$culture === null)\n    {\n      \$culture = sfPropel::getDefaultCulture();\n    }\n";
     if (DataModelBuilder::getBuildProperty('builderAddBehaviors')) {
         $script .= "\n\n    foreach (sfMixer::getCallables('{$this->getClassname()}:doSelectJoin:doSelectJoin') as \$callable)\n    {\n      call_user_func(\$callable, '{$this->getClassname()}', \$c, \$con);\n    }\n\n";
     }
     $script .= "\n    // Set the correct dbName if it has not been overridden\n    if (\$c->getDbName() == Propel::getDefaultDB())\n    {\n      \$c->setDbName(self::DATABASE_NAME);\n    }\n\n    " . $this->getPeerClassname() . "::addSelectColumns(\$c);\n    \$startcol = (" . $this->getPeerClassname() . "::NUM_COLUMNS - " . $this->getPeerClassname() . "::NUM_LAZY_LOAD_COLUMNS) + 1;\n\n    " . $i18nPeerClassName . "::addSelectColumns(\$c);\n\n    \$c->addJoin(" . $pk . ", " . $i18nPk . ");\n    \$c->add(" . $cultureColumnName . ", \$culture);\n\n    \$rs = " . $this->basePeerClassname . "::doSelect(\$c, \$con);\n    \$results = array();\n\n    while(\$rs->next()) {\n";
     if ($table->getChildrenColumn()) {
         $script .= "\n      \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$rs, 1);\n";
     } else {
         $script .= "\n      \$omClass = " . $this->getPeerClassname() . "::getOMClass();\n";
     }
     $script .= "\n      \$cls = Propel::import(\$omClass);\n      \$obj1 = new \$cls();\n      \$obj1->hydrate(\$rs);\n      \$obj1->setCulture(\$culture);\n";
     //            if ($i18nTable->getChildrenColumn()) {
     $script .= "\n      \$omClass = " . $i18nTablePeerBuilder->getPeerClassname() . "::getOMClass(\$rs, \$startcol);\n";
     //            } else {
     //              $script .= "
     //      \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass();
     //";
     //            }
     $script .= "\n      \$cls = Propel::import(\$omClass);\n      \$obj2 = new \$cls();\n      \$obj2->hydrate(\$rs, \$startcol);\n\n      \$obj1->set" . $i18nClassName . "ForCulture(\$obj2, \$culture);\n      \$obj2->set" . $className . "(\$obj1);\n\n      \$results[] = \$obj1;\n    }\n    return \$results;\n  }\n";
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:49,代码来源:SfPeerBuilder.php

示例2: addDoCountJoinAllExcept

 /**
  * Adds the doCountJoinAllExcept*() methods.
  * @param      string &$script The script will be modified in this method.
  */
 protected function addDoCountJoinAllExcept(&$script)
 {
     $table = $this->getTable();
     $fkeys = $table->getForeignKeys();
     // this sep assignment is necessary otherwise sub-loops over
     // getForeignKeys() will cause this to only execute one time.
     foreach ($fkeys as $fk) {
         $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
         $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());
         $excludedClassName = $excludedTable->getPhpName();
         $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
         $excludedTableObjectBuilder = OMBuilder::getNewObjectBuilder($excludedTable);
         $excludedTablePeerBuilder = OMBuilder::getNewPeerBuilder($excludedTable);
         $script .= "\n\n\t/**\n\t * Returns the number of rows matching criteria, joining the related " . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . " table\n\t *\n\t * @param      Criteria \$c\n\t * @param      boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).\n\t * @param      Connection \$con\n\t * @return     int Number of matching rows.\n\t */\n\tpublic static function doCountJoinAllExcept" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$distinct = false, \$con = null)\n\t{\n\t\t// we're going to modify criteria, so copy it first\n\t\t\$criteria = clone \$criteria;\n\n\t\t// clear out anything that might confuse the ORDER BY clause\n\t\t\$criteria->clearSelectColumns()->clearOrderByColumns();\n\t\tif (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {\n\t\t\t\$criteria->addSelectColumn(" . $this->getPeerClassname() . "::COUNT_DISTINCT);\n\t\t} else {\n\t\t\t\$criteria->addSelectColumn(" . $this->getPeerClassname() . "::COUNT);\n\t\t}\n\n\t\t// just in case we're grouping: add those columns to the select statement\n\t\tforeach(\$criteria->getGroupByColumns() as \$column)\n\t\t{\n\t\t\t\$criteria->addSelectColumn(\$column);\n\t\t}\n";
         foreach ($table->getForeignKeys() as $subfk) {
             // want to cover this case, but the code is not there yet.
             if ($subfk->getForeignTableName() != $table->getName()) {
                 $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
                 $joinClassName = $joinTable->getPhpName();
                 $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
                 if ($joinClassName != $excludedClassName) {
                     $lfMap = $subfk->getLocalForeignMapping();
                     foreach ($subfk->getLocalColumns() as $columnName) {
                         $column = $table->getColumn($columnName);
                         $columnFk = $joinTable->getColumn($lfMap[$columnName]);
                         $script .= "\n\t\t\$criteria->addJoin(" . $this->getColumnConstant($column) . ", " . $joinTablePeerBuilder->getColumnConstant($columnFk) . ");\n";
                     }
                 }
             }
         }
         // foreach fkeys
         $script .= "\n\t\t\$rs = " . $this->getPeerClassname() . "::doSelectRS(\$criteria, \$con);\n\t\tif (\$rs->next()) {\n\t\t\treturn \$rs->getInt(1);\n\t\t} else {\n\t\t\t// no rows returned; we infer that means 0 matches.\n\t\t\treturn 0;\n\t\t}\n\t}\n";
     }
     // foreach fk
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:39,代码来源:PHP5ComplexPeerBuilder.php

示例3: addDoSelectWithI18n

  protected function addDoSelectWithI18n(&$script)
  {
    $table = $this->getTable();
    $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
    $className = $table->getPhpName();
    $pks = $table->getPrimaryKey();
    $pk = PeerBuilder::getColumnName($pks[0], $className);

    // get i18n table name and culture column name
    foreach ($table->getReferrers() as $fk)
    {
      $tblFK = $fk->getTable();
      if ($tblFK->getName() == $table->getAttribute('i18nTable'))
      {
        $i18nClassName = $tblFK->getPhpName();

        // FIXME
        $i18nPeerClassName = $i18nClassName.'Peer';

        $i18nTable = $table->getDatabase()->getTable($tblFK->getName());
        $i18nTableObjectBuilder = OMBuilder::getNewObjectBuilder($i18nTable);
        $i18nTablePeerBuilder = OMBuilder::getNewPeerBuilder($i18nTable);
        $i18nPks = $i18nTable->getPrimaryKey();
        $i18nPk = PeerBuilder::getColumnName($i18nPks[0], $i18nClassName);

        $culturePhpName = '';
        $cultureColumnName = '';
        foreach ($tblFK->getColumns() as $col)
        {
          if (('true' == trim(strtolower($col->getAttribute('isCulture')))))
          {
            $culturePhpName = $col->getPhpName();
            $cultureColumnName = PeerBuilder::getColumnName($col, $i18nClassName);
          }
        }
      }
    }

    $script .= "

  /**
   * Selects a collection of $className objects pre-filled with their i18n objects.
   *
   * @return array Array of $className objects.
   * @throws PropelException Any exceptions caught during processing will be
   *     rethrown wrapped into a PropelException.
   */
  public static function doSelectWithI18n(Criteria \$c, \$culture = null, PropelPDO \$con = null)
  {
    // we're going to modify criteria, so copy it first
    \$c = clone \$c;
    if (\$culture === null)
    {
      \$culture = sfPropel::getDefaultCulture();
    }
";

    if ($this->getBuildProperty('builderAddBehaviors'))
    {
      $script .= "

    foreach (sfMixer::getCallables('{$this->getClassname()}:doSelectJoin:doSelectJoin') as \$callable)
    {
      call_user_func(\$callable, '{$this->getClassname()}', \$c, \$con);
    }

";
    }

    $script .= "
    // Set the correct dbName if it has not been overridden
    if (\$c->getDbName() == Propel::getDefaultDB())
    {
      \$c->setDbName(self::DATABASE_NAME);
    }

    ".$this->getPeerClassname()."::addSelectColumns(\$c);
    \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS);

    ".$i18nPeerClassName."::addSelectColumns(\$c);

    \$c->addJoin(".$pk.", ".$i18nPk.");
    \$c->add(".$cultureColumnName.", \$culture);

    \$stmt = ".$this->basePeerClassname."::doSelect(\$c, \$con);
    \$results = array();

    while(\$row = \$stmt->fetch(PDO::FETCH_NUM)) {
";
            if ($table->getChildrenColumn()) {
              $script .= "
      \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, \$startcol);
";
            } else {
              $script .= "
      \$omClass = ".$this->getPeerClassname()."::getOMClass();
";
            }
            $script .= "
      \$cls = Propel::importClass(\$omClass);
//.........这里部分代码省略.........
开发者ID:nationalfield,项目名称:symfony,代码行数:101,代码来源:SfPeerBuilder.php

示例4: addRefFKAdd

 /**
  * Adds the method that adds an object into the referrer fkey collection.
  * @param      string &$script The script will be modified in this method.
  */
 protected function addRefFKAdd(&$script, ForeignKey $refFK)
 {
     $tblFK = $refFK->getTable();
     $className = $refFK->getTable()->getPhpName();
     $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($refFK->getTable());
     $script .= "\n\t/**\n\t * Method called to associate a " . $tblFK->getPhpName() . " object to this object\n\t * through the {$className} foreign key attribute\n\t *\n\t * @param      {$className} \$l {$className}\n\t * @return     void\n\t * @throws     PropelException\n\t */\n\tpublic function add" . $this->getRefFKPhpNameAffix($refFK, $plural = false) . "({$className} \$l)\n\t{\n\t\t\$this->coll" . $this->getRefFKPhpNameAffix($refFK, $plural = true) . "[] = \$l;\n\t\t\$l->set" . $this->getFKPhpNameAffix($refFK, $plural = false) . "(\$this);\n\t}\n";
 }
开发者ID:taryono,项目名称:school,代码行数:11,代码来源:PHP5ComplexObjectBuilder.php

示例5: addRefFKAdd

	/**
	 * Adds the method that adds an object into the referrer fkey collection.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addRefFKAdd(&$script, ForeignKey $refFK)
	{
		$tblFK = $refFK->getTable();
		$className = $refFK->getTable()->getPhpName();

		$joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($refFK->getTable());

		$script .= "
	/**
	 * Method called to associate a ".$tblFK->getPhpName()." object to this object
	 * through the $className foreign key attribute
	 *
	 * @param      $className \$l $className
	 * @return     void
	 * @throws     PropelException
	 */
	public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$l)
	{
		\$this->coll".$this->getRefFKPhpNameAffix($refFK, $plural = true)."[] = \$l;
		\$l->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this);
	}
";
	} // addRefererAdd
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:27,代码来源:PHP5ComplexObjectBuilder.php


注:本文中的OMBuilder::getNewObjectBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。