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


PHP ResultSet::append方法代码示例

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


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

示例1: parseResultSetFromFile

 function parseResultSetFromFile($fd)
 {
     $start = getmicrotime();
     $rs = new ResultSet();
     // read in the whole file
     fseek($fd, 0, SEEK_END);
     $size = ftell($fd);
     fseek($fd, 0, SEEK_SET);
     $wholeFile = fread($fd, $size);
     $lines = explode("\n", $wholeFile);
     unset($wholeFile);
     $wholeFile = "";
     $rec = $this->parseRowFromLine($lines[0]);
     $rs->setColumnNames($rec);
     $rec = $this->parseRowFromLine($lines[1]);
     $rs->setColumnTypes($rec);
     $rec = $this->parseRowFromLine($lines[2]);
     $rs->setColumnDefaultValues($rec);
     $rs->reset();
     $lineCount = count($lines);
     for ($i = 3; $i < $lineCount; ++$i) {
         //$rec=$this->parseRowFromLine($lines[$i]);
         //inlining function parseRowFromLine() for better performance
         $line = $lines[$i];
         if (strlen(trim($line)) == 0) {
             continue;
         }
         // handle Windows \x0D\x0A (\r\n) newlines
         $line = rtrim($line);
         $rec = explode(COLUMN_SEPARATOR_CHAR, $line);
         $rec = str_replace($this->escapeCodeRead, $this->replaceWithRead, $rec);
         if (count($rec) == count($rs->colNames)) {
             $setDefaults = false;
         } else {
             $setDefaults = true;
         }
         if ($rec) {
             $rs->append($setDefaults);
             $rs->rows[$rs->pos]->fields = $rec;
             $rs->rows[$rs->pos]->id = -1;
         }
     }
     debug_print("<i>II: parseResultSetFromFile: " . (getmicrotime() - $start) . " seconds elapsed</i><br>");
     $rs->setColumnAliases(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnTables(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnTableAliases(create_array_fill(count($rs->colNames), ""));
     $rs->setColumnFunctions(create_array_fill(count($rs->colNames), ""));
     $rs->colFuncsExecuted = create_array_fill(count($rs->colNames), false);
     return $rs;
 }
开发者ID:Giannos99,项目名称:HC_Interaction,代码行数:50,代码来源:resultset.php

示例2: 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;
//.........这里部分代码省略.........
开发者ID:Kent-Liang,项目名称:Network-Security,代码行数:101,代码来源:database.php

示例3:

 for ($i = 0; $i < $rowCount; ++$i) {
     if (isset($_POST['delete' . $i])) {
         echo "Row {$i} deleted!<br>";
     } else {
         if (isset($_POST['dup' . $i])) {
             echo "Row {$i} duplicated!<br>";
             $rowsSaved++;
             $rs->appendRow(prep_val_save_arr($vals[$i]));
         }
         $rowsSaved++;
         $rs->appendRow(prep_val_save_arr($vals[$i]));
     }
 }
 echo "{$rowsSaved} Rows saved!<br>";
 if (isset($_POST['append_row'])) {
     $rs->append();
     echo "1 Row appended!<br>";
 }
 echo "colCount: {$colCount}<br>";
 for ($i = 0; $i < $colCount; ++$i) {
     if (isset($_POST['dupCol' . $i])) {
         $rs->duplicateColumn($i);
         echo "Column {$i} duplicated!<br>";
     }
 }
 for ($i = 0; $i < $colCount; ++$i) {
     if (isset($_POST['delCol' . $i])) {
         $rs->removeColumn($i);
         echo "Column {$i} deleted!<br>";
     }
 }
开发者ID:Giannos99,项目名称:HC_Interaction,代码行数:31,代码来源:tbedit.php


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