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