note 36680 deleted from class.com by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 09:15:53 +0000 |
| Subject: | note 36680 deleted from class.com by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212893@lists.php.net to get a copy of this message | ||
Note Submitter: Mihael Peternelj; Slovenia
----
If you wnat to connect to Access MDB Library you can use this small "progy". It works so,
that if someone other accesses the library, it waits for so long to access it again because (as i
know) MDB librarys can be accessed only once at the same time.
<?php
function mdb($sql, $array = 0, $base = "Base.mdb", $timelimit = 5)
{
$r_items = array();
$c = new COM("ADODB.Connection");
$r = false;
$time = time();
$process = $i = 0;
while($r == false && $process <= $timelimit)
{
$deb = $c->open('DRIVER={Microsoft Access Driver (*.mdb)}; Dbq='. realpath($base)
.';');
$r = $c->execute($sql);
$process = time() - $time;
}
if($process >= $timelimit) exit("mdbSQL Query Timeout!");
if(strtolower(substr($sql, 0, 6)) == "insert" or strtolower(substr($sql, 0, 6)) ==
"update" or strtolower(substr($sql, 0, 6)) == "delete") return true;
$num_fields = $r->fields->count();
while (!$r->EOF)
{
for($j = 0; $j < $num_fields; $j++)
{
$key = $r->Fields($j);
if($array == 0) $r_items[$i][$key->name] = $key->value;
else $r_items[$i][$j] = $key->value;
}
$i++;
$r->MoveNext();
}
$r->close();
$c->close();
$r = null;
$c = null;
return $r_items;
}
?>
I got the source from the Manual, what i did is that i made it more compatible and user frendly. :)
I hope it could some day help someone so as it did me...
Greetings from Slovenia!
Mihael Peternelj