國外好東西真的多,現(xiàn)在貼上一個(gè)訪問ACCESS的類!_PHP
Jun 01, 2016 pm 12:35 PMAccess
這是ACCESS的類Class AccessDBM
{
????var $COUNT = 0;
????var $VALUES = array();
????var $FILE = "";
????var $ERROR = "";
????var $EXISTS = false;
????var $STATIC = false;
????var $EXACT = false;
????var $DBM;
//????Older version of PHP can't do the 'new ClassName(args)'
//????Use initilize() if this is the case.
//????*******************************************************
????function AccessDBM ($dbmFile, $static = 0)
????{
????????global $php_errormsg;
????????if(!empty($dbmFile))
????????{
????????????if(file_exists($dbmFile))
????????????{
????????????????$this->EXISTS = true;
????????????}
????????????if($static != 0)
????????????{
????????????????$this->STATIC = true;
????????????}
????????????$this->FILE = $dbmFile;
????????}
????????return;
????}
//????*******************************************************
//????Identical to AccessDBM
????function initialize ($dbmFile, $static = 0)
????{
????????global $php_errormsg;
????????if(!empty($dbmFile))
????????{
????????????if(file_exists($dbmFile))
????????????{
????????????????$this->EXISTS = true;
????????????}
????????????if($static != 0)
????????????{
????????????????$this->STATIC = true;
????????????}
????????????$this->FILE = $dbmFile;
????????}
????????return;
????}
//????*******************************************************
????function add_entry ($key, $val)
????{
????????$results = 0;
????????$dbm = $this->open_dbm();
????????if(!$dbm) { return false; }
????????if(!(dbmreplace($dbm,$key,$val)))
????????{
????????????if(!(dbmexists($dbm,$key)))
????????????{
????????????????$this->ERROR = "Fatal error : could not replace $key with $val";
????????????????$this->close_dbm($dbm);
????????????????return false;
????????????}
????????}
????????$this->close_dbm($dbm);
????????return true;????????
????}
//????*******************************************************
????function remove_entry ($Key)
????{
????????global $php_errormsg;
????????$removed = false;
????????$dbm = $this->open_dbm();
????????if(!$dbm) { return false; }
????????if(dbmexists($dbm,$Key))
????????{
????????????if(!dbmdelete($dbm,$Key))
????????????{
????????????????if(dbmexists($dbm,$Key))
????????????????{
????????????????????$this->ERROR = "Unable to remove [$Key] : [$php_errormsg]";
????????????????????$this->close_dbm($dbm);
????????????????????return false;
????????????????}
????????????}
????????????else
????????????{
????????????????$this->close_dbm($dbm);
????????????????$removed = true;
????????????}
????????}
????????else
????????{
????????????$this->ERROR = "Key [$Key] does not exist";
????????????$this->close_dbm($dbm);
????????????return false;
????????}
????????return true;
????}
//????*******************************************************
????function get_value ($Key)
????{
????????$val = "";
????????$readOnly = true;
????????$dbm = $this->open_dbm($readOnly);
????????if(!$dbm) { return false; }
????????if(dbmexists($dbm,$Key))
????????{
????????????$val = dbmfetch($dbm,$Key);
????????}
????????$this->close_dbm($dbm);
????????return $val;
????}
//????*******************************************************
????function open_dbm ($readOnly = false)
????{
????????global $php_errormsg;
????????if($this->STATIC)
????????{
????????????if(!(empty($this->DBM)))
????????????{
????????????????$dbm = $this->DBM;
????????????????return ($dbm);
????????????}
????????}
????????$fileName = $this->FILE;
????????if(!$this->EXISTS)
????????{
????????????$dbm = @dbmopen($fileName,"n");
????????}
????????else
????????{
????????????if(!$readOnly)
????????????{
????????????????// We want the warning here if we can't be
????????????????// a writer
????????????????$dbm = dbmopen($fileName,"w");
????????????}
????????????else
????????????{
????????????????$dbm = @dbmopen($fileName,"r");
????????????}
????????}
????????if( (!$dbm) or (empty($dbm)) )
????????{
????????????$this->EXISTS = false;
????????????$this->STATIC = false;
????????????$this->ERROR = "Unable to open [$fileName] [$php_errormsg]";
????????????return false;
????????}
????????$this->EXISTS = true;
????????if($this->STATIC)
????????{
????????????$this->DBM = $dbm;
????????}
????????return ($dbm);
????}
//????*******************************************************
????function find_key ($search)
????{
????????$val = "";
????????$dbm = $this->open_dbm(1);
????????if(!$dbm) { return false; }
????????if(dbmexists($dbm,$search))
????????{
????????????// Wow an exact match
????????????$val = dbmfetch($dbm,$search);
????????????$this->close_dbm($dbm);
????????????$this->EXACT = true;
????????????return $val;
????????}
????????else
????????{
????????????$this->EXACT = false;
????????????$key = dbmfirstkey($dbm);
????????????while ($key)
????????????{
????????????????// Strip the first whitespace char and
????????????????// everything after it.
????????????????$test = ereg_replace(" .*","",$key);
????????????????if(eregi("^$test",$search))
????????????????{
????????????????????$val = dbmfetch($dbm,$key);
????????????????????$this->close_dbm($dbm);
????????????????????error_log("Test [$test] matched [$search]",0);
????????????????????return $val;
????????????????}
????????????????$key = dbmnextkey($dbm,$key);
????????????}
????????}
????????// Didn't find it
????????$this->close_dbm($dbm);
????????return false;
????}
//????*******************************************************
????// Returns the KEY
????function find_val ($search)
????{
????????$this->EXACT = false;
????????$Dbase = $this->get_all();
????????if(empty($Dbase))
????????{
????????????error_log("ERROR Dbase is empty $DB->ERROR",0);
????????????return false;
????????}
????????while ( list ( $key, $val ) = each ($Dbase) )
????????{
????????????if($search == $val)
????????????{
????????????????$this->EXACT=true;
????????????????return $key;
????????????}
????????????else
????????????{
????????????????// Strip the first whitespace char and
????????????????// everything after it.
????????????????$test = ereg_replace(" .*","",$val);
????????????????if(eregi("^$test",$search))
????????????????{
????????????????????$this->EXACT = false;
????????????????????return $key;
????????????????}
????????????}
????????}
????????// Didn't find it
????????return false;
????}
//????*******************************************************
????function get_all ()
????{
????????$values = array();
????????$count = 0;
????????$readOnly = true;
????????$dbm = $this->open_dbm($readOnly);
????????if(!$dbm) { return false; }
????????$key = dbmfirstkey($dbm);
????????while ($key)
????????{
????????????$val = dbmfetch($dbm,$key);
????????????$values[$key] = $val;
????????????$count++;
????????????$key = dbmnextkey($dbm, $key);
????????}
????????$this->COUNT = $count;
????????$this->VALUES = $values;
????????$this->close_dbm($dbm);
????????return $values;
????}
//????*******************************************************
????function close_dbm ($dbm)
????{
????????$results = false;
????????if(!$this->STATIC)
????????{
????????????$results = dbmclose($dbm);
????????}
????????return $results;
????}
//????*******************************************************
????function static_close()
????{
????????$results = false;
????????if(!$this->DBM)
????????{
????????????$this->ERROR = "No static DBM to close";
????????????return false;
????????}
????????$dbm = $this->DBM;
????????$results = dbmclose($dbm);
????????unset($this->DBM);
????????return $results;
????}
//????*******************************************************
}
?>
這個(gè)連接上!
include("class.AccessDBM.php3");
????$static = true;
????$dbase = new AccessDBM("/path/to/file.dbm",$static);
????register_shutdown_function($dbase->static_close());
????if(!$dbase->add_entry("cdi","cdi@thewebmasters.net))
????{
????????echo "Error adding entry: $dbase->ERROR\n";
????}
????$Values = $dbase->get_all()
????while ( list ($key,$val) = each ($Values) )
????{
????????echo "Key: $key??Val: $val \n";
????}
????exit;

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Users may have seen the term wapi when using the Internet, but for some people they definitely don’t know what wapi is. The following is a detailed introduction to help those who don’t know to understand. What is wapi: Answer: wapi is the infrastructure for wireless LAN authentication and confidentiality. This is like functions such as infrared and Bluetooth, which are generally covered near places such as office buildings. Basically they are owned by a small department, so the scope of this function is only a few kilometers. Related introduction to wapi: 1. Wapi is a transmission protocol in wireless LAN. 2. This technology can avoid the problems of narrow-band communication and enable better communication. 3. Only one code is needed to transmit the signal

In iOS17, Apple has more control over what apps can see in photos. Read on to learn how to manage app access by app. In iOS, Apple's in-app photo picker lets you share specific photos with the app, while the rest of your photo library remains private. Apps must request access to your entire photo library, and you can choose to grant the following access to apps: Restricted Access – Apps can only see images that you can select, which you can do at any time in the app or by going to Settings > ;Privacy & Security>Photos to view selected images. Full access – App can view photos

How to solve the problem that Tomcat cannot successfully access the war package after deploying it requires specific code examples. As a widely used Java Web server, Tomcat allows developers to package their own developed Web applications into war files for deployment. However, sometimes we may encounter the problem of being unable to successfully access the war package after deploying it. This may be caused by incorrect configuration or other reasons. In this article, we'll provide some concrete code examples that address this dilemma. 1. Check Tomcat service

We can access the metadata of audio files using Mutagen and the eyeD3 module in Python. For video metadata we can use movies and the OpenCV library in Python. Metadata is data that provides information about other data, such as audio and video data. Metadata for audio and video files includes file format, file resolution, file size, duration, bitrate, etc. By accessing this metadata, we can manage media more efficiently and analyze the metadata to obtain some useful information. In this article, we will take a look at some of the libraries or modules provided by Python for accessing metadata of audio and video files. Access audio metadata Some libraries for accessing audio file metadata are - using mutagenesis

A JsonNode is Jackson's JSON tree model that can read JSON into JsonNode instances and write JsonNode into JSON. We can use Jackson to read JSON into a JsonNode by creating an ObjectMapper instance and calling the readValue() method. We can access fields, arrays or nested objects using the get() method of the JsonNode class. We can use the asText() method to return a valid string representation and convert the node's value to Javaint using the asInt() method of the JsonNode class. In the example below we can access Json

Sharing folders is indeed an extremely useful feature in a home or business network environment. It allows you to easily share folders with other users, thereby facilitating file transfer and sharing. Win10 Home Edition shared folder cannot be accessed Solution: Solution 1: Check network connection and user permissions When trying to use Win10 shared folders, we first need to confirm whether the network connection and user permissions are normal. If there is a problem with the network connection or the user does not have permission to access the shared folder, it may result in inaccessibility. 1. First, please ensure that the network connection is smooth so that the computer and the computer where the shared folder is located are in the same LAN and can communicate normally. 2. Secondly check the user permissions to confirm that the current user has permission to share files.

Methods to check foreign real-time hot searches: 1. Social media platforms; 2. News websites and applications; 3. Search engine hot search rankings; 4. Online forums and communities; 5. Follow foreign celebrities and influencers. Detailed introduction: 1. Social media platforms are one of the most common ways to learn about foreign real-time hot searches, the most famous of which is Twitter, which is widely used to share news and hot topics; 2. News websites and applications, many international News websites and applications provide real-time hot search functions to learn about hot topics in foreign countries, such as BBC, CNN, etc.

How to solve the problem of accessing and calling external resources in PHP development requires specific code examples. In PHP development, we often encounter situations where we need to access and call external resources, such as API interfaces, third-party libraries or other server resources. When dealing with these external resources, we need to consider how to access and call safely while ensuring performance and reliability. This article describes several common solutions and provides corresponding code examples. 1. Use the curl library to call external resources. Curl is a very powerful open source library.
