本文整理汇总了PHP中ResultSet::addColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::addColumn方法的具体用法?PHP ResultSet::addColumn怎么用?PHP ResultSet::addColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultSet
的用法示例。
在下文中一共展示了ResultSet::addColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSelectQuery
function executeSelectQuery(&$sqlQuery)
{
global $g_sqlGroupingFuncs;
global $g_sqlSingleRecFuncs;
$resultSets = array();
// create a copy
$aliases = $sqlQuery->colAliases;
$funcs = $sqlQuery->colFuncs;
// Read all Tables
for ($i = 0; $i < count($sqlQuery->tables); ++$i) {
debug_printb("<br>[executeSelectQuery] Reading table " . $sqlQuery->tables[$i] . "<br>");
if (!($resultSets[$i] = $this->readTable($sqlQuery->tables[$i]))) {
print_error_msg("Reading Table " . $sqlQuery->tables[$i] . " failed");
return false;
}
$resultSets[$i]->setColumnTableForAll($sqlQuery->tables[$i]);
$resultSets[$i]->setColumnTableAliasForAll($sqlQuery->tableAliases[$i]);
// set all functions to the ResultSet of the current table
// if table and column name matches
debug_printb("[executeSelectQuery] Setting functions for the current table:<br>");
for ($j = 0; $j < count($funcs); ++$j) {
if (!$funcs[$j] || !$sqlQuery->colNames[$j]) {
continue;
}
if ($sqlQuery->colTables[$j] == $sqlQuery->tables[$i] || $sqlQuery->colTables[$j] == $sqlQuery->tableAliases[$i]) {
$colNr = $resultSets[$i]->findColNrByAttrs($sqlQuery->colNames[$j], $sqlQuery->colTables[$j], "");
if ($colNr == NOT_FOUND) {
continue;
}
// create a new column for each function
$resultSets[$i]->addColumn($sqlQuery->colNames[$j], $sqlQuery->colAliases[$j], $sqlQuery->colTables[$j], "", "str", "", $funcs[$j], "", true);
$funcs[$j] = "";
}
}
// set all aliases where table, column name and function matches
debug_printb("[executeSelectQuery] Setting aliases for the current table:<br>");
for ($j = 0; $j < count($aliases); ++$j) {
if (!$aliases[$j]) {
continue;
}
if ($sqlQuery->colTables[$j] == $sqlQuery->tables[$i] || $sqlQuery->colTables[$j] == $sqlQuery->tableAliases[$i]) {
if (($colNr = $resultSets[$i]->findColNrByAttrs($sqlQuery->colNames[$j], $sqlQuery->colTables[$j], $sqlQuery->colFuncs[$j])) != NOT_FOUND) {
$resultSets[$i]->setColumnAlias($colNr, $aliases[$j]);
$aliases[$j] = "";
}
}
}
if (TXTDBAPI_DEBUG) {
debug_printb("<br>[executeSelectQuery] Dump of Table {$i} (" . $sqlQuery->tables[$i] . "):<br>");
$resultSets[$i]->dump();
}
}
// set remaining functions to the ResultSet where column name matches
debug_printb("[executeSelectQuery] Setting remaining functions where column name matches:<br>");
for ($i = 0; $i < count($resultSets); ++$i) {
for ($j = 0; $j < count($funcs); ++$j) {
if (!$funcs[$j] || !$sqlQuery->colNames[$j]) {
continue;
}
$colNr = $resultSets[$i]->findColNrByAttrs($sqlQuery->colNames[$j], "", "");
if ($colNr == NOT_FOUND) {
// 'text' or 123 ? => add column
if (!(is_numeric($sqlQuery->colNames[$j]) || has_quotes($sqlQuery->colNames[$j]))) {
continue;
}
debug_print("Adding function with quoted string or number paremeter!<br>");
}
// create a new column for each function
$resultSets[$i]->addColumn($sqlQuery->colNames[$j], $sqlQuery->colAliases[$j], $sqlQuery->colTables[$j], "", "str", "", $funcs[$j], "", true);
$funcs[$j] = "";
}
}
// set remaining aliases where column name and function matches
debug_printb("[executeSelectQuery] Setting remaining aliases where column name and function matches:<br>");
for ($i = 0; $i < count($resultSets); ++$i) {
for ($j = 0; $j < count($aliases); ++$j) {
if (!$aliases[$j]) {
continue;
}
if (($colNr = $resultSets[$i]->findColNrByAttrs($sqlQuery->colNames[$j], "", $sqlQuery->colFuncs[$j])) != NOT_FOUND) {
$resultSets[$i]->setColumnAlias($colNr, $aliases[$j]);
$aliases[$j] = "";
}
}
}
debug_printb("[executeSelectQuery] Executing single-rec functions (on the separate ResultSet's):<br>");
// execute single-rec functions (on the separate ResultSet's)
for ($i = 0; $i < count($resultSets); ++$i) {
$resultSets[$i]->executeSingleRecFuncs();
}
// A query without tables ? => make a dummy ResultSet
$dummyResultSet = false;
if (count($sqlQuery->tables) == 0) {
$dummyResultSet = true;
$rsMaster = new ResultSet();
$rsMaster->addColumn("(dummy)", "(dummy)", "(dummy)", "(dummy)", "str", "(dummy)", "", "", true);
$rsMaster->append();
// else: real ResultSet
} else {
$dummyResultSet = false;
//.........这里部分代码省略.........