本文整理汇总了PHP中QueryBuilder::getStubQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getStubQueryBuilder方法的具体用法?PHP QueryBuilder::getStubQueryBuilder怎么用?PHP QueryBuilder::getStubQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getStubQueryBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queryMethods
public function queryMethods(QueryBuilder $builder)
{
$script = '';
$queryClassName = $builder->getStubQueryBuilder()->getClassname();
$createColumnConstant = $this->getColumnConstant('create_column', $builder);
if ($this->withUpdatedAt()) {
$updateColumnConstant = $this->getColumnConstant('update_column', $builder);
$script .= "\n/**\n * Filter by the latest updated\n *\n * @param int \$nbDays Maximum age of the latest update in days\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function recentlyUpdated(\$nbDays = 7)\n{\n return \$this->addUsingAlias({$updateColumnConstant}, time() - \$nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);\n}\n\n/**\n * Order by update date desc\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function lastUpdatedFirst()\n{\n return \$this->addDescendingOrderByColumn({$updateColumnConstant});\n}\n\n/**\n * Order by update date asc\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function firstUpdatedFirst()\n{\n return \$this->addAscendingOrderByColumn({$updateColumnConstant});\n}\n";
}
$script .= "\n/**\n * Filter by the latest created\n *\n * @param int \$nbDays Maximum age of in days\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function recentlyCreated(\$nbDays = 7)\n{\n return \$this->addUsingAlias({$createColumnConstant}, time() - \$nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);\n}\n\n/**\n * Order by create date desc\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function lastCreatedFirst()\n{\n return \$this->addDescendingOrderByColumn({$createColumnConstant});\n}\n\n/**\n * Order by create date asc\n *\n * @return {$queryClassName} The current query, for fluid interface\n */\npublic function firstCreatedFirst()\n{\n return \$this->addAscendingOrderByColumn({$createColumnConstant});\n}";
return $script;
}
示例2: queryMethods
public function queryMethods(QueryBuilder $builder)
{
$foreignKey = $this->getI18nTable()->getBehavior('symfony_i18n_translation')->getForeignKey();
$join = in_array($this->getBuildProperty('propel.useLeftJoinsInDoJoinMethods'), array(true, null), true) ? 'LEFT' : 'INNER';
$localeColumn = $this->getI18nTable()->getBehavior('symfony_i18n_translation')->getCultureColumn()->getPhpName();
$queryClass = $builder->getStubQueryBuilder()->getClassname();
$i18nRelationName = $builder->getRefFKPhpNameAffix($foreignKey);
return <<<EOF
/**
* Adds a JOIN clause to the query using the i18n relation
*
* @param string \$culture Locale to use for the join condition, e.g. 'fr_FR'
* @param string \$relationAlias optional alias for the relation
* @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return {$queryClass} The current query, for fluid interface
*/
public function joinI18n(\$culture = null, \$relationAlias = null, \$joinType = Criteria::{$join}_JOIN)
{
if (null === \$culture)
{
\$culture = sfPropel::getDefaultCulture();
}
\$relationName = \$relationAlias ? \$relationAlias : '{$i18nRelationName}';
return \$this
->join{$i18nRelationName}(\$relationAlias, \$joinType)
->addJoinCondition(\$relationName, \$relationName . '.{$localeColumn} = ?', \$culture);
}
/**
* Adds a JOIN clause to the query and hydrates the related I18n object.
* Shortcut for \$c->joinI18n(\$culture)->with()
*
* @param string \$culture Locale to use for the join condition, e.g. 'fr_FR'
* @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return {$queryClass} The current query, for fluid interface
*/
public function joinWithI18n(\$culture = null, \$joinType = Criteria::{$join}_JOIN)
{
\$this
->joinI18n(\$culture, null, \$joinType)
->with('{$i18nRelationName}');
\$this->with['{$i18nRelationName}']->setIsWithOneToMany(false);
return \$this;
}
/**
* Use the I18n relation query object
*
* @see useQuery()
*
* @param string \$culture Locale to use for the join condition, e.g. 'fr_FR'
* @param string \$relationAlias optional alias for the relation
* @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return {$i18nRelationName}Query A secondary query class using the current class as primary query
*/
public function useI18nQuery(\$culture = null, \$relationAlias = null, \$joinType = Criteria::{$join}_JOIN)
{
return \$this
->joinI18n(\$culture, \$relationAlias, \$joinType)
->useQuery(\$relationAlias ? \$relationAlias : '{$i18nRelationName}', '{$i18nRelationName}Query');
}
EOF;
}