CakeFest 2024: The Official CakePHP Conference

DBA 関数

目次

  • dba_close — DBA データベースを閉じる
  • dba_delete — キーが指す DBA エントリを削除する
  • dba_exists — キーが存在するかどうかを確認する
  • 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 — データベースを同期する
add a note

User Contributed Notes 4 notes

up
2
Franz Korntner
12 years ago
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();
?>
up
0
kevinphpdotnet at stormtide dot ca
20 years ago
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.
up
0
djm at web dot us dot uu dot net
24 years ago
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.
To Top