A recently written PHP Access control class (PHPODBCAccess)

Source: Internet
Author: User
Tags php mysql
Recently, I received a website application of PHP + Access and perspiration. I have never used php + Access before. I have participated in some other functions by referring to the access functions written by others, encapsulated as a class, it is very convenient to call, although it has not been tested,

Recently, I received a website application called PHP Access and sweated. I have never used php Access before. refer to the access function written by others and I have participated in some other functions and encapsulated them into a class, I feel that the call is quite convenient. although I have never tested it, I feel that PHP Access is not as fast as PHP MySQL.

The code is as follows:

PHP code:

--------------------------------------------------------------------
// FileName: class. php
// Summary: Access database control class
// Application model:
// $ Databasepath = 'database. mdb ';
// $ Dbusername = '';
// $ Dbpassword = '';
// Include_once ('class. php ');
// $ Access = new Access ($ databasepath, $ dbusername, $ dbpassword );

--------------------------------------------------------------------
Class Access
{
Var $ databasepath, $ constr, $ dbusername, $ dbpassword, $ link;
Function Access ($ databasepath, $ dbusername, $ dbpassword)
{
$ This-> databasepath = $ databasepath;
$ This-> username = $ dbusername;
$ This-> password = $ dbpassword;
$ This-> connect ();
}

Function connect ()
{
$ This-> constr = 'driver = {Microsoft Access DRIVER (*. mdb)}; DBQ = '. realpath ($ this-> databasepath );
$ This-> link = odbc_connect ($ this-> constr, $ this-> username, $ this-> password, SQL _CUR_USE_ODBC );
Return $ this-> link;
// If ($ this-> link) echo 'congratulations, the database connection is successful! ';
// Else echo 'database connection failed! ';
}

Function query ($ SQL)
{
Return @ odbc_exec ($ this-> link, $ SQL );
}

Function first_array ($ SQL)
{
Return odbc_fetch_array ($ this-> query ($ SQL ));
}

Function fetch_row ($ query)
{
Return odbc_fetch_row ($ query );
}

Function total_num ($ SQL) // Retrieve the total number of records
{
Return odbc_num_rows ($ this-> query ($ SQL ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.