note 36680 added to class.com

From: Date: Sat, 18 Oct 2003 09:22:26 +0000
Subject: note 36680 added to class.com
Groups: php.notes 
Request: Send a blank email to php-notes+get-58803@lists.php.net to get a copy of this message
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. 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 ---- Manual Page -- http://www.php.net/manual/en/class.com.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36680 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36680&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36680&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58803) next »