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


PHP Table::getChildrenColumn方法代码示例

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


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

示例1: addFixLevels

 protected function addFixLevels(&$script)
 {
     $objectClassName = $this->objectClassName;
     $queryClassName = $this->queryClassName;
     $tableMapClassName = $this->tableMapClassName;
     $useScope = $this->behavior->useScope();
     $script .= "\n/**\n * Update the tree to allow insertion of a leaf at the specified position\n *";
     if ($useScope) {
         $script .= "\n * @param      integer \$scope    scope column value";
     }
     $script .= "\n * @param      ConnectionInterface \$con    Connection to use.\n */\nstatic public function fixLevels(" . ($useScope ? "\$scope, " : "") . "ConnectionInterface \$con = null)\n{\n    \$c = new Criteria();";
     if ($useScope) {
         $script .= "\n    \$c->add({$objectClassName}::SCOPE_COL, \$scope, Criteria::EQUAL);";
     }
     $script .= "\n    \$c->addAscendingOrderByColumn({$objectClassName}::LEFT_COL);\n    \$dataFetcher = {$queryClassName}::create(null, \$c)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find(\$con);\n    ";
     if (!$this->table->getChildrenColumn()) {
         $script .= "\n    // set the class once to avoid overhead in the loop\n    \$cls = {$tableMapClassName}::getOMClass(false);";
     }
     $script .= "\n    \$level = null;\n    // iterate over the statement\n    while (\$row = \$dataFetcher->fetch()) {\n\n        // hydrate object\n        \$key = {$tableMapClassName}::getPrimaryKeyHashFromRow(\$row, 0);\n        /** @var \$obj {$objectClassName} */\n        if (null === (\$obj = {$tableMapClassName}::getInstanceFromPool(\$key))) {";
     if ($this->table->getChildrenColumn()) {
         $script .= "\n            // class must be set each time from the record row\n            \$cls = {$tableMapClassName}::getOMClass(\$row, 0);\n            \$cls = substr('.'.\$cls, strrpos('.'.\$cls, '.') + 1);\n            " . $this->builder->buildObjectInstanceCreationCode('$obj', '$cls') . "\n            \$obj->hydrate(\$row);\n            {$tableMapClassName}::addInstanceToPool(\$obj, \$key);";
     } else {
         $script .= "\n            " . $this->builder->buildObjectInstanceCreationCode('$obj', '$cls') . "\n            \$obj->hydrate(\$row);\n            {$tableMapClassName}::addInstanceToPool(\$obj, \$key);";
     }
     $script .= "\n        }\n\n        // compute level\n        // Algorithm shamelessly stolen from sfPropelActAsNestedSetBehaviorPlugin\n        // Probably authored by Tristan Rivoallan\n        if (\$level === null) {\n            \$level = 0;\n            \$i = 0;\n            \$prev = array(\$obj->getRightValue());\n        } else {\n            while (\$obj->getRightValue() > \$prev[\$i]) {\n                \$i--;\n            }\n            \$level = ++\$i;\n            \$prev[\$i] = \$obj->getRightValue();\n        }\n\n        // update level in node if necessary\n        if (\$obj->getLevel() !== \$level) {\n            \$obj->setLevel(\$level);\n            \$obj->save(\$con);\n        }\n    }\n    \$dataFetcher->close();\n}\n";
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:26,代码来源:NestedSetBehaviorQueryBuilderModifier.php

示例2: testAddColumn

 public function testAddColumn()
 {
     $table = new Table('books');
     $column = $this->getColumnMock('created_at');
     $this->assertInstanceOf('Propel\\Generator\\Model\\Column', $table->addColumn($column));
     $this->assertNull($table->getChildrenColumn());
     $this->assertTrue($table->requiresTransactionInPostgres());
     $this->assertTrue($table->hasColumn($column));
     $this->assertTrue($table->hasColumn('CREATED_AT', true));
     $this->assertSame($column, $table->getColumnByPhpName('CreatedAt'));
     $this->assertCount(1, $table->getColumns());
     $this->assertSame(1, $table->getNumColumns());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:TableTest.php


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