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


PHP DataObjectSet::count方法代码示例

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


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

示例1: generateExportFileData

	function generateExportFileData(&$numColumns, &$numRows) {
		$separator = $this->csvSeparator;
		$csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList;
		$fileData = '';
		$columnData = array();
		$fieldItems = new DataObjectSet();
		
		if($this->csvHasHeader) {
			$fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\"";
			$fileData .= "\n";
		}

		if(isset($this->customSourceItems)) {
			$items = $this->customSourceItems;
		} else {
			$dataQuery = $this->getCsvQuery();
			$records = $dataQuery->execute();
			$sourceClass = $this->sourceClass;
			$dataobject = new $sourceClass();
			$items = $dataobject->buildDataObjectSet($records, 'DataObjectSet');
		}
		
		if($items && $items->count()) foreach($items as $item) {
			// create a TableListField_Item to support resolving of
			// relation-fields in dot notation via TableListField_Item->Fields()
			if($item) $fieldItems->push(new TableListField_Item($item, $this));
		}
		
		// temporary override to adjust TableListField_Item behaviour
		$this->setFieldFormatting(array());
		$this->fieldList = $csvColumns;

		if($fieldItems) {
			foreach($fieldItems as $fieldItem) {
				$fields = $fieldItem->Fields();
				$columnData = array();
				if($fields) foreach($fields as $field) {
					$value = $field->Value;
					
					// TODO This should be replaced with casting
					if(array_key_exists($field->Name, $this->csvFieldFormatting)) {
						$format = str_replace('$value', "__VAL__", $this->csvFieldFormatting[$field->Name]);
						$format = preg_replace('/\$([A-Za-z0-9-_]+)/','$item->$1', $format);
						$format = str_replace('__VAL__', '$value', $format);
						eval('$value = "' . $format . '";');
					}
					
					$value = str_replace(array("\r", "\n"), "\n", $value);
					$tmpColumnData = "\"" . str_replace("\"", "\"\"", $value) . "\"";
					$columnData[] = $tmpColumnData;
				}
				$fileData .= implode($separator, $columnData);
				$fileData .= "\n";
			}
			
			$numColumns = count($columnData);
			$numRows = $fieldItems->count();
			return $fileData;
		} else {
			return null;
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:62,代码来源:TableListField.php

示例2: CustomerViewableOrderStatusLogs

 /**
  * returns all the logs that can be viewed by the customer.
  * @return null | DataObjectSet
  */
 function CustomerViewableOrderStatusLogs()
 {
     $customerViewableOrderStatusLogs = new DataObjectSet();
     $logs = $this->OrderStatusLogs();
     if ($logs) {
         foreach ($logs as $log) {
             if (!$log->InternalUseOnly) {
                 $customerViewableOrderStatusLogs->push($log);
             }
         }
         if ($customerViewableOrderStatusLogs->count()) {
             return $customerViewableOrderStatusLogs;
         }
     }
     return null;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:20,代码来源:Order.php

示例3: getStickyTopics

 /**
  * Return the Sticky Threads
  * @return DataObjectSet
  */
 function getStickyTopics($include_global = true)
 {
     $standard = DataObject::get("ForumThread", "\"ForumThread\".\"ForumID\" = {$this->ID} AND \"ForumThread\".\"IsSticky\" = 1", "MAX(\"PostList\".\"Created\") DESC", "INNER JOIN \"Post\" AS \"PostList\" ON \"PostList\".\"ThreadID\" = \"ForumThread\".\"ID\"");
     if (!$standard || !$standard->count()) {
         $standard = new DataObjectSet();
     }
     if ($include_global) {
         // We have to join posts through their forums to their holders, and then restrict the holders to just the parent of this forum.
         $global = DataObject::get("ForumThread", "\"ForumThread\".\"IsGlobalSticky\" = 1", "MAX(\"PostList\".\"Created\") DESC", "INNER JOIN \"Post\" AS \"PostList\" ON \"PostList\".\"ThreadID\" = \"ForumThread\".\"ID\"");
         if (!$global || !$global->count()) {
             $global = new DataObjectSet();
         }
         $standard->merge($global);
         $standard->removeDuplicates();
     }
     if ($standard->count()) {
         $standard->sort('PostList.Created');
     }
     return $standard;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:24,代码来源:Forum.php

示例4: generateExportFileData

 function generateExportFileData(&$numColumns, &$numRows)
 {
     $separator = $this->csvSeparator;
     $csvColumns = $this->fieldListCsv ? $this->fieldListCsv : $this->fieldList;
     $fileData = '';
     $columnData = array();
     $fieldItems = new DataObjectSet();
     if ($this->csvHasHeader) {
         $fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\"";
         $fileData .= "\n";
     }
     if (isset($this->customSourceItems)) {
         $items = $this->customSourceItems;
     } else {
         $dataQuery = $this->getCsvQuery();
         $items = $dataQuery->execute();
     }
     // temporary override to adjust TableListField_Item behaviour
     $this->setFieldFormatting(array());
     $this->fieldList = $csvColumns;
     if ($items) {
         foreach ($items as $item) {
             if (is_array($item)) {
                 $className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName'];
                 $item = new $className($item);
             }
             $fieldItem = new $this->itemClass($item, $this);
             $fields = $fieldItem->Fields(false);
             $columnData = array();
             if ($fields) {
                 foreach ($fields as $field) {
                     $value = $field->Value;
                     // TODO This should be replaced with casting
                     if (array_key_exists($field->Name, $this->csvFieldFormatting)) {
                         $format = str_replace('$value', "__VAL__", $this->csvFieldFormatting[$field->Name]);
                         $format = preg_replace('/\\$([A-Za-z0-9-_]+)/', '$item->$1', $format);
                         $format = str_replace('__VAL__', '$value', $format);
                         eval('$value = "' . $format . '";');
                     }
                     $value = str_replace(array("\r", "\n"), "\n", $value);
                     $tmpColumnData = '"' . str_replace('"', '\\"', $value) . '"';
                     $columnData[] = $tmpColumnData;
                 }
             }
             $fileData .= implode($separator, $columnData);
             $fileData .= "\n";
             $item->destroy();
             unset($item);
             unset($fieldItem);
         }
         $numColumns = count($columnData);
         $numRows = $fieldItems->count();
         return $fileData;
     } else {
         return null;
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:57,代码来源:TableListField.php

示例5: AlternativesPerProduct

 /**
  * returns a list of alternatives per product (if any)
  * @return NULL | DataObjectSet
  */
 function AlternativesPerProduct()
 {
     $dos = new DataObjectSet();
     for ($i = 1; $i < 6; $i++) {
         $alternativeField = "Alternative" . $i . "ID";
         if ($this->{$alternativeField}) {
             $product = DataObject::get_by_id("Product", $this->{$alternativeField});
             if ($product) {
                 $dos->push($product);
             }
         }
     }
     if ($dos && $dos->count()) {
         return $dos;
     }
     return null;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-repeatorders,代码行数:21,代码来源:RepeatOrder.php


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