當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Finder::addOrderCol方法代碼示例

本文整理匯總了PHP中Finder::addOrderCol方法的典型用法代碼示例。如果您正苦於以下問題:PHP Finder::addOrderCol方法的具體用法?PHP Finder::addOrderCol怎麽用?PHP Finder::addOrderCol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Finder的用法示例。


在下文中一共展示了Finder::addOrderCol方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: importEntities

 private function importEntities()
 {
     $file = Singleton::create("DOMXmlFactory")->fromFile("config/service.xml");
     $root = $file->getRootElement();
     $entityEls = $root->getChildren("entity");
     $this->entities = array();
     foreach ($entityEls as $entityEl) {
         $name = $entityEl->getAttribute("name");
         $table = $entityEl->getAttribute("table");
         $entity = new Entity($name, $table);
         // Insert properties
         foreach ($entityEl->getChildren("column") as $property) {
             $propertyName = $property->getAttribute("name");
             $type = $property->getAttribute("type");
             $size = $property->getAttribute("size");
             $entityName = $property->getAttribute("entity");
             $mappingTable = $property->getAttribute("mapping-table");
             $primary = $property->getAttribute("primary") == "true";
             $autoIncrement = $property->getAttribute("auto-increment") == "true";
             if ($primary) {
                 $entity->addPKProperty(new PrimaryKeyProperty($propertyName, $type, $size, $autoIncrement));
             } elseif ($type == "Object") {
                 $entity->addOneToOneProperty(new OneToOneProperty($propertyName, $entityName));
             } elseif ($type == "Collection" && !$mappingTable) {
                 $entity->addOneManyProperty(new OneToManyProperty($propertyName, $entityName));
             } elseif ($mappingTable) {
                 $entity->addManyToManyProperty(new ManyToManyProperty($propertyName, $entityName, $mappingTable));
             } else {
                 $entity->addProperty(new Property($propertyName, $type, $size));
             }
         }
         // Insert finders
         foreach ($entityEl->getChildren("finder") as $finderEl) {
             $finderName = $finderEl->getAttribute("name");
             $unique = $finderEl->getAttribute("unique");
             $cacheable = $finderEl->getAttribute("cacheable");
             $unique = $unique === "true";
             $cacheable = !($cacheable === "false");
             $finder = new Finder($entity, $finderName, $unique, $cacheable);
             foreach ($finderEl->getChildren("finder-column") as $fcEl) {
                 $name = $fcEl->getAttribute("name");
                 $comparator = $fcEl->getAttribute("comparator");
                 if (empty($comparator)) {
                     $comparator = "=";
                 }
                 $finder->addFinderColumn(new FinderColumn($name, $comparator));
             }
             $orderEls = $finderEl->getChildren("order");
             if ($orderEls->size() > 1) {
                 throw new ServiceBuilderException("Multiple order elements defined for finder {$finderName}");
             }
             if ($orderEls->size() == 1) {
                 $orderEl = $orderEls->getFirst();
                 foreach ($orderEl->getChildren("order-column") as $ocEl) {
                     $ocName = $ocEl->getAttribute("name");
                     $ocOrderBy = $ocEl->getAttribute("order-by");
                     $finder->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
                 }
             }
             $entity->addFinder($finder);
         }
         // Insert order
         $orderEls = $entityEl->getChildren("order");
         if ($orderEls->size() > 1) {
             throw new ServiceBuilderException("Multiple order elements defined for entity {$entity->getName()}");
         }
         if ($orderEls->size() == 1) {
             $orderEl = $orderEls->get(0);
             foreach ($orderEl->getChildren("order-column") as $ocEl) {
                 $ocName = $ocEl->getAttribute("name");
                 $ocOrderBy = $ocEl->getAttribute("order-by");
                 $entity->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
             }
         }
         $entity->validate();
         // Add entity
         $this->entities[$entity->getName()] = $entity;
     }
 }
開發者ID:aeberh,項目名稱:php-movico,代碼行數:79,代碼來源:ServiceBuilder.php


注:本文中的Finder::addOrderCol方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。