本文整理汇总了PHP中ResultSet::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::dump方法的具体用法?PHP ResultSet::dump怎么用?PHP ResultSet::dump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultSet
的用法示例。
在下文中一共展示了ResultSet::dump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groupRows
function groupRows(&$sqlQuery, $useLimit = false)
{
debug_printb("[groupRows] Grouping rows...<br>");
global $g_sqlGroupingFuncs;
$ar_limit = $sqlQuery->limit;
$groupColumns = $sqlQuery->groupColumns;
$groupColNrs = array();
// use column numbers (faster)
for ($i = 0; $i < count($groupColumns); ++$i) {
$groupColNrs[$i] = $this->findColNrByFullName($groupColumns[$i]);
if ($groupColNrs[$i] == NOT_FOUND) {
print_error_msg("Column '" . $groupColumns[$i] . "' not found!");
return false;
}
}
// calc limit
if (!$useLimit) {
$limit = -1;
} else {
if (!isset($ar_limit[0]) && !isset($ar_limit[1])) {
$limit = -1;
} else {
if (count($ar_limit) > 1) {
$limit = $ar_limit[0] + $ar_limit[1];
} else {
$limit = $ar_limit[0];
}
}
}
$rs = new ResultSet();
$rs->copyColumData($this);
$groupedRows = array();
$groupedValues = array();
$colNamesCount = count($this->colNames);
$this->reset();
while (++$this->pos < count($this->rows)) {
// generate key
$currentValues = array();
foreach ($groupColNrs as $groupColNr) {
array_push($currentValues, md5($this->rows[$this->pos]->fields[$groupColNr]));
}
$groupedRecsKey = join("-", $currentValues);
for ($i = 0; $i < $colNamesCount; ++$i) {
$groupedValues[$groupedRecsKey][$i][] = $this->rows[$this->pos]->fields[$i];
}
// key doesn't exist ? add record an set key into array
if (!array_key_exists($groupedRecsKey, $groupedRows)) {
$groupedRows[$groupedRecsKey] = 1;
$rs->append(false);
$rs->rows[$rs->pos]->fields = $this->rows[$this->pos]->fields;
$rs->rows[$rs->pos]->id = $this->rows[$this->pos]->id;
}
if ($limit != -1) {
if (count($rs->rows) >= $limit) {
break;
}
}
}
--$this->pos;
if (TXTDBAPI_VERBOSE_DEBUG) {
echo "<b>RS dump in groupRows():<br></b>";
$rs->dump();
}
$groupFuncSrcColNr = -1;
// the source column for the column with grouping functions
// calculate the result of the functions
for ($i = 0; $i < count($rs->colFuncs); ++$i) {
if (in_array($rs->colFuncs[$i], $g_sqlGroupingFuncs)) {
if (TXTDBAPI_DEBUG) {
debug_print("Searching source for grouping function " . $rs->colFuncs[$i] . "(");
if ($rs->colTables[$i]) {
debug_print($rs->colTables[$i] . ".");
}
debug_print($rs->colNames[$i] . "): ");
}
if ($rs->colFuncs[$i] == "COUNT" && $rs->colNames[$i] == "*") {
$groupFuncSrcColNr = 0;
} else {
$groupFuncSrcColNr = $this->findColNrByAttrs($rs->colNames[$i], $rs->colTables[$i], "");
}
if ($groupFuncSrcColNr == NOT_FOUND) {
print_error_msg("Column " . $rs->colNames[$i] . ", " . $rs->colTables[$i] . " not found!");
return null;
}
foreach ($groupedValues as $key => $value) {
$groupedValues[$key][$i][0] = execGroupFunc($rs->colFuncs[$i], $groupedValues[$key][$groupFuncSrcColNr]);
}
}
}
// put the results back
$rs->reset();
foreach ($groupedValues as $key => $value) {
$rs->next();
for ($i = 0; $i < $colNamesCount; ++$i) {
$rs->rows[$rs->pos]->fields[$i] = $groupedValues[$key][$i][0];
}
}
return $rs;
}