-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.php
More file actions
36 lines (29 loc) · 1.05 KB
/
test2.php
File metadata and controls
36 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$db = './storage/NCR_MANILA.mdb';
$dbName = $db;
$driver = 'MDBTools';
$dbh = odbc_connect("DRIVER=$driver; DBQ=$dbName;", '', '');
if ($dbh === false) {
echo 'unable to connect.';
exit;
}
// Table with column num, name test
$sql = "SELECT * FROM NCR_MANILA"; // The rules are the same as above
//$sth = odbc_exec($dbh, $sql);
// LOCK_EX will prevent anyone else writing to the file at the same time
// PHP_EOL will add linebreak after each line
//$txt = "data-to-add";
//file_put_contents('sample.txt', $txt.PHP_EOL, FILE_APPEND | LOCK_EX);
// Second option is this
//$myfile = fopen("./sample.txt", "a") or die("Unable to open file!");
// Because of binding to the column, only the judgment result will be returned to $ flg
//$values = []; // Array to assign the value
//while ($flg = odbc_fetch_object($sth)) {
// $txt = sprintf("%s : %s\n", $flg->REFID, $flg->STREET);
// fwrite($myfile, PHP_EOL.$txt);
//}
//fclose($myfile);
$tables = odbc_tables($dbh, null,null,null,'TABLE');
while (($row = odbc_fetch_array($tables))) {
print_r($row);
}