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


PHP OMBuilder::declareClasses方法代码示例

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


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

示例1: addReorder

 protected function addReorder(&$script)
 {
     $this->builder->declareClasses('Propel');
     $peerClassname = $this->peerClassname;
     $columnGetter = 'get' . $this->behavior->getColumnForParameter('rank_column')->getPhpName();
     $columnSetter = 'set' . $this->behavior->getColumnForParameter('rank_column')->getPhpName();
     $script .= "\n/**\n * Reorder a set of sortable objects based on a list of id/position\n * Beware that there is no check made on the positions passed\n * So incoherent positions will result in an incoherent list\n *\n * @param     array     \$order id => rank pairs\n * @param     PropelPDO \$con   optional connection\n * @return    boolean true if the reordering took place, false if a database problem prevented it\n * @throws Exception\n */\npublic function reorder(array \$order, PropelPDO \$con = null)\n{\n    if (\$con === null) {\n        \$con = Propel::getConnection({$peerClassname}::DATABASE_NAME);\n    }\n\n    \$con->beginTransaction();\n    try {\n        \$ids = array_keys(\$order);\n        \$objects = \$this->findPks(\$ids, \$con);\n        foreach (\$objects as \$object) {\n            \$pk = \$object->getPrimaryKey();\n            if (\$object->{$columnGetter}() != \$order[\$pk]) {\n                \$object->{$columnSetter}(\$order[\$pk]);\n                \$object->save(\$con);\n            }\n        }\n        \$con->commit();\n\n        return true;\n    } catch (Exception \$e) {\n        \$con->rollback();\n        throw \$e;\n    }\n}\n";
 }
开发者ID:Bonscho,项目名称:Propel,代码行数:8,代码来源:SortableBehaviorQueryBuilderModifier.php

示例2: queryMethods

 /**
  * @param OMBuilder $builder
  * @return string
  */
 public function queryMethods(OMBuilder $builder)
 {
     $builder->declareClasses('BasePeer');
     $this->builder = $builder;
     $script = '';
     $this->addSetCacheEnable($script);
     $this->addSetCacheDisable($script);
     $this->addIsCacheEnable($script);
     $this->addGetCacheKey($script);
     $this->addResetCacheKey($script);
     $this->addSetCacheKey($script);
     $this->addSetLocale($script);
     $this->addSetLifeTime($script);
     $this->addGetLifeTime($script);
     $this->addAdd($script);
     $this->addClear($script);
     $this->addFind($script);
     $this->addFindOne($script);
     $this->addPurgeFromCache($script);
     $this->addDeleteFromCache($script);
     return $script;
 }
开发者ID:stevleibelt,项目名称:PropelDataCacheBehavior,代码行数:26,代码来源:DataCacheBehaviorQueryBuilderModifier.php


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