If you need a 'download data' button that automatically fires up a spreadsheet (like Excel), find that fputcsv() isn't working as expected, that none of the installed DBA database engines create a spreadsheet that can be opened, and that XLS generating components are just too heavy weight, then this might just hit the spot:
<?php
// simple table to present
$data = array(
array('col1','col2'),
array(1,2),
array(3,4)
);
// pretend content (which is XML) is XLS native
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"sheet.xls\";" );
// construct skeleton
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = $dom->preserveSpaces = true; // optional
$n = new DOMProcessingInstruction('mso-application', 'progid="Excel.Sheet"');
$dom->appendChild($n);
$workbook = $dom->appendChild(new DOMElement('Workbook'));
$workbook->setAttribute('xmlns','urn:schemas-microsoft-com:office:spreadsheet');
$workbook->setAttribute('xmlns:o','urn:schemas-microsoft-com:office:office');
$workbook->setAttribute('xmlns:x','urn:schemas-microsoft-com:office:excel');
$workbook->setAttribute('xmlns:ss','xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet');
$workbook->setAttribute('xmlns:html','http://www.w3.org/TR/REC-html40');
$styles = $workbook->appendChild(new DOMElement('Styles'));
$style = $styles->appendChild(new DOMElement('Style'));
$style->setAttribute('ss:ID','Default');
$worksheet = $workbook->appendChild(new DOMElement('Worksheet'));
$worksheet->setAttribute('ss:Name','sheet1');
$xmltable = $worksheet->appendChild(new DOMElement('Table'));
// populate with data
foreach ($data as $datarow) {
$xmlrow = $xmltable->appendChild(new DOMElement('Row'));
foreach ($datarow as $datacell) {
$xmlcell = $xmlrow->appendChild(new DOMElement('Cell'));
$xmldata = $xmlcell->appendChild(new DOMElement('Data', $datacell));
$xmldata->setAttribute('ss:Type', is_numeric($datacell) ? 'Number' : 'String');
}
}
// display and quit
echo $dom->saveXML();
?>
PHP.mk документација
— Класата Dba\Connection
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
ref.dba.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + преведен приказ
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
ref.dba.php
— Класата Dba\Connection
Референца за `ref.dba.php` со подобрена типографија и навигација.
— Класата Dba\Connection
Содржина
- dba_close — Затвори база на податоци DBA
- dba_delete — Затвори DBA база на податоци
- dba_exists — Избриши DBA запис определен со клуч
- dba_fetch — Провери дали клучот постои
- dba_firstkey — Преземи податоци определени со клуч
- dba_handlers — Преземи прв клуч
- dba_insert — Наведи ги сите достапни ракувачи
- dba_key_split — Вметни запис
- dba_list — Подели клуч во текстуална репрезентација во репрезентација на низа
- dba_nextkey — Наведи ги сите отворени датотеки со бази на податоци
- dba_open — Преземи следниот клуч
- dba_optimize — Отвори база на податоци
- dba_popen — Оптимизирај база на податоци
- dba_replace — Отвори база на податоци постојано
- dba_sync — Замени или вметни запис
Белешки од корисници 4 белешки
— Синхронизирај база на податоци ¶
пред 14 години
Франц Корнтнер ¶
пред 22 години
When using db4 on redhat 7.3 you may get signal 11s on the apache child processes. The installation test scripts will report that db4 is working correctly as the cli will not sig 11 out. The solution is to check to see if mod_rewrite is installed with apache, if it is either dereference it from libdb.so.3 or build apache without mod rewrite. Once this is done you will no longer have your child processes dying out and db4 will work. If you do not get a sig 11 after dba_open just ignore this comment.
kevinphpdotnet на stormtide точка ca ¶
ian at eiloart dot com
With db2, you need to call dba_sync() to get the data written to disk; the examples are missing this. db2 uses
the BTREE file format, not the more common HASH.
BTREE is faster, though, in my tests, so it's a good
choice.
doppelbauer на gmail точка com ¶
19 години пред
Benchmark test:
http://qdbm.sourceforge.net/benchmark.pdf