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


PHP rs2csv函数代码示例

本文整理汇总了PHP中rs2csv函数的典型用法代码示例。如果您正苦于以下问题:PHP rs2csv函数的具体用法?PHP rs2csv怎么用?PHP rs2csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: export_results

function export_results($people, $format)
{
    global $db, $export_format_array;
    $keys = implode(",", $people);
    $rs = $db->Execute('select ' . $export_format_array[$format] . ' from supporter where supporter_KEY in (' . $keys . ')');
    $rs->MoveFirst();
    $out = rs2csv($rs);
    return $out;
    #$fp = fopen('/tmp/jaguar_export.csv', "w");
    #if ($fp) {
    #  rs2csvfile($rs, $fp);
    #  fclose($fp);
    #}
    #return $fp;
}
开发者ID:radicaldesigns,项目名称:jaguar,代码行数:15,代码来源:export.php

示例2: ereg_replace

    $field14 = ", moduserdata.field14 as '" . ereg_replace("'", "", $Recordset1->Fields("field14text")) . "' ";
}
if ($Recordset1->Fields("field15text") != NULL) {
    $field15 = ", moduserdata.field15 as '" . ereg_replace("'", "", $Recordset1->Fields("field15text")) . "' ";
}
if ($Recordset1->Fields("field16text") != NULL) {
    $field16 = ", moduserdata.field16 as '" . ereg_replace("'", "", $Recordset1->Fields("field16text")) . "' ";
}
if ($Recordset1->Fields("field17text") != NULL) {
    $field17 = ", moduserdata.field17 as '" . ereg_replace("'", "", $Recordset1->Fields("field17text")) . "' ";
}
if ($Recordset1->Fields("field18text") != NULL) {
    $field18 = ", moduserdata.field18 as '" . ereg_replace("'", "", $Recordset1->Fields("field18text")) . "' ";
}
if ($Recordset1->Fields("field19text") != NULL) {
    $field19 = ", moduserdata.field19 as '" . ereg_replace("'", "", $Recordset1->Fields("field19text")) . "' ";
}
if ($Recordset1->Fields("field20text") != NULL) {
    $field20 = ", moduserdata.field20 as '" . ereg_replace("'", "", $Recordset1->Fields("field20text")) . "' ";
}
$sql = "select distinct ";
$sql .= "moduserdata.Organization, moduserdata.FirstName, moduserdata.LastName,  moduserdata.EmailAddress, moduserdata.Phone, moduserdata.Fax,    moduserdata.Address,  moduserdata.Address2,   moduserdata.City,  states.state,  moduserdata.PostalCode, moduserdata.Country, moduserdata.WebPage ";
$sql .= " {$field1} {$field2} {$field3} {$field4} {$field5} {$field6} {$field7} {$field8} {$field9} {$field10} {$field11} {$field12} {$field13} {$field14} {$field15} {$field16} {$field17} {$field18} {$field19} {$field20} ";
//$sql .= " moduserdata.field1 as '$field1', moduserdata.field2 as '$field2', moduserdata.field3 as '$field3', moduserdata.field4 as '$field4',  moduserdata.field5 as '$field5', moduserdata.field6 as '$field6', moduserdata.field7 as '$field7', moduserdata.field8 as '$field8', moduserdata.field9 as '$field9',   moduserdata.field10 as '$field10'";
$sql .= " from moduserdata left join states on moduserdata.State=states.id where modinid={$bval}  ";
//echo $sql."<br>";
$rs = $dbcon->Execute($sql);
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename={$filename}");
print rs2csv($rs);
# return a string, CSV formatprint '<hr>';
开发者ID:radicalsuz,项目名称:amp,代码行数:31,代码来源:export.php

示例3: fopen

            echo $fprestf;
            ?>
</b></td>
		</tr>

		<?php 
            $cont++;
            $rs->MoveNext();
        }
        include_once $ADODB_PATH . '/toexport.inc.php';
        $db->conn->SetFetchMode(ADODB_FETCH_ASSOC);
        $rs = $db->query($sql);
        $archivoCSV = $ruta_raiz . "/bodega/tmp/B_{$krd}.xls";
        $fp = fopen($archivoCSV, "w");
        if ($fp) {
            fwrite($fp, iconv("UTF-8", "ISO-8859-1", rs2csv($rs)));
            fclose($fp);
        }
        require_once $ADODB_PATH . 'excel.inc.php';
        //$tit=array("RADICADO","FECHA_RADICADO","NRO_ORDEN","FECHA_INICIAL","FECHA_FINAL","VIGENCIA","DEPENDENCIA","QUERELLANTE_O_CONTRATISTA","QUERELLADO_O_OBJETO","DOCUMENTO_DE_IDENTIDAD","DOCUMENTO_QUERELLADO","DIRECCION","SERIE","SUBSERIE","TIPO","FOLIOS","ZONA","CARRO","CARA","ESTANTE","ENTREPANO","CAJA","CAJA_HASTA","UNIDAD_DOCUMENTAL","NRO_CARPETAS","OBSERVACIONES","INDICADORES_DE_DETERIORO","MATERIAL_INSERTADO","AUTO","PRESTAMO");
        $tit = array("NRO_ORDEN", "SERIE", "SUBSERIE", "TIPO", "FOLIOS", "CAJA", "NRO_CARPETAS");
        $gerar = new sql2excel($tit, $sql, $db);
        //using $db pointer by default
    } else {
        echo "DEBE SELECCIONAR O LLENAR ALGUNA OPCION";
    }
    ?>
</table>
<br>
<center><?php 
    echo $cont;
开发者ID:johnfelipe,项目名称:orfeo,代码行数:31,代码来源:busqueda_central.php

示例4: testdb


//.........这里部分代码省略.........
    $cnt = 0;
    while ($rs && !$rs->EOF) {
        $cnt += 1;
        if (!isset($rs->fields['firstname'])) {
            print "<br><b>ASSOC returned numeric field</b></p>";
            break;
        }
        $rs->MoveNext();
    }
    if ($cnt != 3) {
        print "<br><b>Count should be 3, instead it was {$cnt}</b></p>";
    }
    $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    if ($db->sysDate) {
        $saved = $db->debug;
        $db->debug = 1;
        $rs = $db->Execute("select {$db->sysDate} from ADOXYZ where id=1");
        if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) {
            print "<p><b>Invalid date {$rs->fields[0]}</b></p>";
        } else {
            print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";
        }
        print_r($rs->FetchField(0));
        print time();
        $db->debug = $saved;
    } else {
        print "<p><b>\$db->sysDate not defined</b></p>";
    }
    print "<p>Test CSV</p>";
    include_once '../toexport.inc.php';
    //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    $rs = $db->SelectLimit('select id,firstname,lastname,created,\'He, he\' he,\'"\' q  from ADOXYZ', 10);
    print "<pre>";
    print rs2csv($rs);
    print "</pre>";
    $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The	"young man", he said\' from ADOXYZ', 10);
    if (PHP_VERSION < 5) {
        print "<pre>";
        rs2tabout($rs);
        print "</pre>";
    }
    #print " CacheFlush ";
    #$db->CacheFlush();
    $date = $db->SQLDate('d-m-M-Y-\\QQ h:i:s A');
    $sql = "SELECT {$date} from ADOXYZ";
    print "<p>Test SQLDate: " . htmlspecialchars($sql) . "</p>";
    $rs = $db->SelectLimit($sql, 1);
    $d = date('d-m-M-Y-') . 'Q' . ceil(date('m') / 3.0) . date(' h:i:s A');
    if (!$rs) {
        Err("SQLDate query returned no recordset");
    } else {
        if ($d != $rs->fields[0]) {
            Err("SQLDate 1 failed expected: <br>act:{$d} <br>sql:" . $rs->fields[0]);
        }
    }
    $date = $db->SQLDate('d-m-M-Y-\\QQ h:i:s A', $db->DBDate("1974-02-25"));
    $sql = "SELECT {$date} from ADOXYZ";
    print "<p>Test SQLDate: " . htmlspecialchars($sql) . "</p>";
    $db->debug = 1;
    $rs = $db->SelectLimit($sql, 1);
    $ts = ADOConnection::UnixDate('1974-02-25');
    $d = date('d-m-M-Y-', $ts) . 'Q' . ceil(date('m', $ts) / 3.0) . date(' h:i:s A', $ts);
    if (!$rs) {
        Err("SQLDate query returned no recordset");
        echo $db->ErrorMsg(), '<br>';
    } else {
开发者ID:mvpphet,项目名称:IntranetPaper,代码行数:67,代码来源:test.php

示例5: header

/**
 * Format Include
 * Handles all of the data formatting from $recordSet to 
 * format of choice (xml,json,jsonp,kml,csv)
 */
if ($format == 'xml') {
    require_once "xml.pdo.inc.php";
    header("Content-Type: text/xml");
    echo rs2xml($recordSet);
} elseif ($format == 'json') {
    require_once "json.pdo.inc.php";
    header("Content-Type: application/json");
    echo rs2json($recordSet);
} else {
    if ($format == 'kml') {
        require_once "kml.pdo.inc.php";
        header("Content-Type: application/vnd.google-earth.kml+xml");
        header("Content-Disposition: attachment; filename=kml_export.kml");
        echo rs2kml($recordSet);
    } else {
        if ($format == 'csv') {
            require_once "csv.pdo.inc.php";
            header("Content-Type: text/csv");
            header("Content-Disposition: attachment; filename=csv_export.csv");
            echo rs2csv($recordSet);
        } else {
            trigger_error("Caught Exception: format must be xml or json.", E_USER_ERROR);
        }
    }
}
开发者ID:oliviervanre,项目名称:GeolocOptinAdhoc,代码行数:30,代码来源:format.inc.php

示例6: testdb


//.........这里部分代码省略.........
    $cnt = 0;
    while ($rs && !$rs->EOF) {
        $cnt += 1;
        if (!isset($rs->fields['firstname'])) {
            print "<br><b>ASSOC returned numeric field</b></p>";
            break;
        }
        $rs->MoveNext();
    }
    if ($cnt != 3) {
        print "<br><b>Count should be 3, instead it was {$cnt}</b></p>";
    }
    $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    if ($db->sysDate) {
        $saved = $db->debug;
        $db->debug = 1;
        $rs = $db->Execute("select {$db->sysDate} from adoxyz where id=1");
        if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) {
            print "<p><b>Invalid date {$rs->fields[0]}</b></p>";
        } else {
            print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";
        }
        print_r($rs->FetchField(0));
        print time();
        $db->debug = $saved;
    } else {
        print "<p><b>\$db->sysDate not defined</b></p>";
    }
    print "<p>Test CSV</p>";
    include_once '../toexport.inc.php';
    //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The	"young man", he said\' from adoxyz', 10);
    print "<pre>";
    print rs2csv($rs);
    print "</pre>";
    $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The	"young man", he said\' from adoxyz', 10);
    print "<pre>";
    rs2tabout($rs);
    print "</pre>";
    //print " CacheFlush ";
    //$db->CacheFlush();
    $date = $db->SQLDate('d-m-Y-\\QQ');
    $sql = "SELECT {$date} from ADOXYZ";
    print "<p>Test SQLDate: " . htmlspecialchars($sql) . "</p>";
    $rs = $db->SelectLimit($sql, 1);
    $d = date('d-m-Y-') . 'Q' . ceil(date('m') / 3.0);
    if ($d != $rs->fields[0]) {
        Err("SQLDate failed expected: {$d}, sql:" . $rs->fields[0]);
    }
    print "<p>Test Filter</p>";
    $rs = $db->SelectLimit('select * from ADOXYZ where id < 3 order by id');
    $rs = RSFilter($rs, 'do_strtolower');
    if (trim($rs->fields[1]) != 'caroline' && trim($rs->fields[2]) != 'miranda') {
        err('**** RSFilter failed');
        print_r($rs->fields);
    }
    rs2html($rs);
    $db->debug = 1;
    print "<p>Test Replace</p>";
    $ret = $db->Replace('adoxyz', array('id' => 1, 'firstname' => 'Caroline', 'lastname' => 'Miranda'), array('id'), $autoq = true);
    if (!$ret) {
        echo "<p>Error in replacing existing record</p>";
    } else {
        $saved = $db->debug;
        $db->debug = 0;
        $savec = $ADODB_COUNTRECS;
开发者ID:alexpagnoni,项目名称:adodb,代码行数:67,代码来源:test.php

示例7: csv

 /**
  * converts a result set or an array to a CSV file
  *
  * @param $data \b array or result set
  * @param $filename \b filename for download
  * @param $echo \b specifies whether to echo the csv or return as a string.  Defaults to true (echo)
  */
 public static function csv($data, $filename = null, $echo = true, $quote_all = false)
 {
     if ($filename) {
         header('Content-type: application/octet-stream');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         self::downloadfix();
     } elseif ($echo) {
         header('Content-type: text/plain');
     }
     //end if
     $output = '';
     if (is_array($data)) {
         //build the headers
         $fields = array_keys($data[0]);
         $csvstring = '';
         foreach ($fields as $value) {
             if ($csvstring != '') {
                 $csvstring .= ',';
             }
             //end if
             $csvstring .= is_numeric($value) ? $value : '"' . str_replace('"', '\\"', $value) . '"';
         }
         //end foreach
         $output .= $csvstring . "\n";
         // build the data rows
         foreach ($data as $d) {
             $csvstring = '';
             foreach ($d as $value) {
                 if ($csvstring != '') {
                     $csvstring .= ',';
                 }
                 //end if
                 if ($quote_all) {
                     $csvstring .= '"' . str_replace('"', '\\"', $value) . '"';
                 } else {
                     $csvstring .= is_numeric($value) ? $value : '"' . str_replace('"', '\\"', $value) . '"';
                 }
             }
             //end foreach
             $output .= $csvstring . "\n";
         }
         //end foreach
     } elseif ($data instanceof ADORecordSet) {
         require_once 'adodb5/toexport.inc.php';
         $output = rs2csv($data);
     } else {
         $output = $data;
     }
     //end else
     if ($filename || $echo) {
         echo $output;
     } else {
         return $output;
     }
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:62,代码来源:PSU.php

示例8: csv2rs

 /**
  * Execute SQL, caching recordsets.
  *
  * @param secs2cache	seconds to cache data, set to 0 to force query
  * @param sql		SQL statement to execute
  * @param [inputarr]	holds the input data  to bind to
  * @param [arg3]	reserved for john lim for future use
  * @return 		RecordSet or false
  */
 function &CacheExecute($secs2cache, $sql, $inputarr = false, $arg3 = false)
 {
     $md5file = $this->_gencachename($sql);
     $err = '';
     if ($secs2cache > 0) {
         $rs =& csv2rs($md5file, $err, $secs2cache);
     } else {
         $err = 'Timeout 1';
         $rs = false;
     }
     if (!$rs) {
         if ($this->debug) {
             print " {$md5file} cache failure: {$err}<br>";
         }
         $rs =& $this->Execute($sql, $inputarr, $arg3);
         if ($rs) {
             $eof = $rs->EOF;
             $rs =& $this->_rs2rs($rs);
             $txt =& rs2csv($rs, false, $sql);
             if (!adodb_write_file($md5file, $txt, $this->debug) && $this->debug) {
                 print ' Cache write error<br>';
             }
             if ($rs->EOF && !$eof) {
                 $rs =& csv2rs($md5file, $err);
             }
         } else {
             @unlink($md5file);
         }
     } else {
         if ($this->debug) {
             $ttl = $rs->timeCreated + $secs2cache - time();
             print " {$md5file} success ttl={$ttl}<br>";
         }
     }
     return $rs;
 }
开发者ID:qoire,项目名称:portal,代码行数:45,代码来源:adodb.inc.php

示例9: csv2rs

 /**
  * Execute SQL, caching recordsets.
  *
  * @param secs2cache	seconds to cache data, set to 0 to force query
  * @param sql		SQL statement to execute
  * @param [inputarr]	holds the input data  to bind to
  * @param [arg3]	reserved for john lim for future use
  * @return 		RecordSet or false
  */
 function &CacheExecute($secs2cache, $sql, $inputarr = false, $arg3 = false)
 {
     include_once ADODB_DIR . '/adodb-csvlib.inc.php';
     // cannot cache if $inputarr set
     if ($inputarr) {
         return $this->Execute($sql, $inputarr, $arg3);
     }
     $md5file = $this->_gencachename($sql);
     $err = '';
     if ($secs2cache > 0) {
         $rs =& csv2rs($md5file, $err, $secs2cache);
     } else {
         $err = 'Timeout 1';
         $rs = false;
     }
     if (!$rs) {
         // no cached rs found
         if ($this->debug) {
             print " {$md5file} cache failure: {$err}<br>";
         }
         $rs =& $this->Execute($sql, $inputarr, $arg3);
         if ($rs) {
             $eof = $rs->EOF;
             $rs =& $this->_rs2rs($rs);
             $txt =& rs2csv($rs, false, $sql);
             if (!adodb_write_file($md5file, $txt, $this->debug) && $this->debug) {
                 print ' Cache write error<br>';
             }
             if ($rs->EOF && !$eof) {
                 $rs =& csv2rs($md5file, $err);
                 $rs->connection =& $this;
                 // Pablo suggestion
             }
         } else {
             @unlink($md5file);
         }
     } else {
         // ok, set cached object found
         $rs->connection =& $this;
         // Pablo suggestion
         if ($this->debug) {
             $ttl = $rs->timeCreated + $secs2cache - time();
             print " {$md5file} success ttl={$ttl}<br>";
         }
     }
     return $rs;
 }
开发者ID:qoire,项目名称:portal,代码行数:56,代码来源:adodb.inc.php

示例10: err

} else {
    $remote = $HTTP_SERVER_VARS["REMOTE_ADDR"];
}
// IIS
if (empty($HTTP_GET_VARS['sql'])) {
    err('No SQL');
}
if (!empty($ACCEPTIP)) {
    if ($remote != '127.0.0.1' && $remote != $ACCEPTIP) {
        err("Unauthorised client: '{$remote}'");
    }
}
$conn =& ADONewConnection($driver);
if (!$conn->Connect($host, $uid, $pwd, $database)) {
    err($conn->ErrorNo() . $sep . $conn->ErrorMsg());
}
$sql = undomq($HTTP_GET_VARS['sql']);
if (isset($HTTP_GET_VARS['nrows'])) {
    $nrows = $HTTP_GET_VARS['nrows'];
    $offset = isset($HTTP_GET_VARS['offset']) ? $HTTP_GET_VARS['offset'] : -1;
    $rs = $conn->SelectLimit($sql, $nrows, $offset);
} else {
    $rs = $conn->Execute($sql);
}
if ($rs) {
    //$rs->timeToLive = 1;
    print rs2csv($rs, $conn, $sql);
    $rs->Close();
} else {
    err($conn->ErrorNo() . $sep . $conn->ErrorMsg());
}
开发者ID:qoire,项目名称:portal,代码行数:31,代码来源:server.php

示例11: list_export

function list_export(&$udm, $options, $ids)
{
    global $base_path;
    #require_once('CSV/CSV.php');
    require_once 'adodb/toexport2.inc.php';
    if (is_array($ids)) {
        $udm->set_sql['where'] .= " and id IN(" . join(",", $ids) . ") ";
    }
    if ($rs = $udm->returnRS()) {
        header("Content-type: application/csv");
        header("Content-Disposition: attachment; filename=" . $options['filename']);
        $output = rs2csv($rs);
    }
    return $output;
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:15,代码来源:UserlistCSV.inc.php


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