本文整理汇总了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";
}
示例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());
}