Class Access
Object
|
--Database
|
--Access
Classes extended from Access:
Location: Program_Root/pdbc/Access.php
Class Access provides a simple interface for connecting to an ODBC datasource (that is, an Access Database File)
In order to use this class, you must create an ODBC DSN for your database file, which, if you are
using this class, will probably already be common knowledge for you. If not, try googling for a
quick tutorial on it, or open your control panel and double click "ODBC Data Sources".
This class is a little different, in that it will NOT automatically connect to the datasource
when it is instantiated, instead, there is a seperate method for connection.
My main reason for doing it this way is two fold:
1) Should the information passed to the constructor be incorrect, it will not foil the entire
execution flow of the script, but will allow for easier exception handling.
2) If you needed to delete the reference to the ODBC/Access datasource before all of the references
to the object were finished, you would have a more unified way of recreating the connection. If
the connection mechanism were in the constructor, the only way to reconnect to the database would
be to reinstatiate the class, which is not always a good idea on the fly, and is never a good idea
if you are trying to keep objects and memory usage to a minimum.
- Package:
pdbc
- Version:
$Revision: 0.1 $ $Date: 2003/04/15 8:51 PM $
- Since:
Japha 1.0
@
- Author:
Ryan Gantt
@
Class Variable Summary
Inherited Class Variable Summary
Method Summary
Inherited Method Summary
Inherited From Class Database
Inherited From Class Object
Variable Detail
Method Detail
- void close()
Usage: close ( )
Turns the current access point to the ODBC/Access datasource into a null reference.
Parameters
Info
- void connect()
Usage: connect ( )
Creates a new ODBC/Access database connection
Uses the current DSN/User/Pass info to make the connection
Will throw an exception is there is an error in the connection
Parameters
Info
- Throws:
DatabaseException
- Access:
public
- Object[] fetch_array()
Usage: fetch_array ( $handle )
Retunrs the result set generated by the passed query as a good 'ol array.
Parameters
- handle $handle - The executed query / result set
@
Info
- Return:
fetched array
- Access:
public
- void fetch_array()
Usage: fetch_array ( $handle )
Parameters
Info
- void fetch_object()
Usage: fetch_object ( $handle )
Parameters
Info
- boolean is_connected()
Usage: is_connected ( )
Returns true if the connection has been.. well.. connected.
Parameters
Info
- Return:
ture iff the dsn is connected
- Access:
public
- int num_fields()
Usage: num_fields ( $handle )
Will get the number of fields that is being returned by the passed query.
Note: This is different from getNumRows, as it returns 'horizontally'.
Parameters
- handle $handle - The executed query / result set
@
Info
- Return:
the number of fields fetched by the query
- Access:
public
- int num_rows()
Usage: num_rows ( $handle )
Will return the number of rows that are being returned by the passed query
Note: This is different from getNumFields, as it returns 'vertically'.
Parameters
- handle $handle - The executed query / result set
@
Info
- Return:
the number of rows fetched by the query
- Access:
public
- ODBC query()
Usage: query ( $query )
Execute a predefined query on the datasource.
Will throw a DatabaseException if there is an error with the query.
Parameters
- query $query - Query String to run against the ODBC/Access datasource
Info
- Return:
An executed OCDBC query / result set
@
- Throws:
DatabaseException
@
- Access:
public
- void __construct()
Usage: __construct ( $dsn, $user, [$pass = ''] )
Unified constructor for Access.
Takes a DSN, username, and password as parameters, but the password can be
omitted if there is no password set on the ODBC Datasource.
This will NOT create a connection to the database, only load up the user variables.
Connections can be made fromt the connect() method once Access has been instantiated.
Parameters
Info