System.Data
[ class tree: System.Data ] [ index: System.Data ] [ all elements ]

Class: TAdodb

Source Location: /Data/TAdodb.php

Class Overview

TComponent
   |
   --TAdodb

TAdodb class

Class Details

[line 85]
TAdodb class

TAdodb is a wrapper class of the ADODB ADOConnection class. For more information about the ADODB library, see http://adodb.sourceforge.net/.

Before establishing a DB connection, you need to set either the DataSourceName property or Driver, Host, User, Password, and Database properties. If both are provided, the DataSourceName takes precedence. The explanation of these properties are very straightforward and can be found in ADODB documentations. Below are some examples about the DataSourceName property,

  1. mysql://user:password@localhost/dbname
  2. postgres7:

Note, if any part of DataSourceName (e.g. password, localhost) contains special characters such as /:? you need to rawurlencode it first. For example,

  1. $adodb=new TAdodb;
  2. $adodb->DataSourceName="sqlite://".rawurlencode('c:/databases/profile.db');

You can call any method implemented in ADOConnection class via TAdodb, such as TAdodb::Execute(), TAdodb::FetchRow(), and so on. The method calls will be passed to ADOConnection class.

TAdodb implements two methods open() and close() to allow explicitly establishing and closing DB connection. The open() method will be invoked automatically to prepare a ADOConnection object if any ADOConnection class method is invoked.

Namespace: System.Data

Properties

  • DataSourceName, string
    Gets or sets the data source name (DSN) of the DB connection.
  • Driver, string
    Gets or sets the driver of the DB, e.g. 'mysql', 'sqlite', 'postgres7'. See ADODB documentation for the supported drivers.
  • Host, string
    Gets or sets the host name/ip of the DB server. A port number may be included as well, for example, 'localhost:6789'.
  • User, string
    Gets or sets the username for logging into DB server.
  • Password, string
    Gets or sets the password for logging into DB server.
  • Database, string
    Gets or sets the name of the database to be used.
  • FetchMode, string, default=TAdodb::FETCH_DEFAULT
    Gets or sets how data is fetched from DB server. Possible values include TAdodb::FETCH_ASSOCIATIVE, TAdodb::FETCH_NUMERIC, TAdodb::FETCH_BOTH, TAdodb::FETCH_DEFAULT. See ADODB documentation for more details about the fetch mode.
  • PersistentConnection, boolean, default=false
    Gets or sets whether the DB connection is persistent or not.




version:  v1.0, last update on 2004/08/13 21:44:52
author:  Qiang Xue <qiang.xue@gmail.com>


[ Top ]

Constants

Methods


Inherited Variables

Inherited Methods

Class: TComponent

TComponent::__construct()
Constructor.
TComponent::addChild()
Adds a child component.
TComponent::addParsedObject()
Handles a component or string met in template.
TComponent::attachEventHandler()
Attaches a handler function to an event.
TComponent::bindProperty()
Sets up the binding between a property and an expression.
TComponent::canGetProperty()
Determines whether a property can be read.
TComponent::canSetProperty()
Determines whether a property can be written.
TComponent::createComponent()
Creates a child component.
TComponent::dataBind()
Performs the databinding for this component.
TComponent::evaluateExpression()
Evaluates a PHP expression.
TComponent::evaluateStatements()
Evaluates a list of PHP statements.
TComponent::findObject()
Finds an object by its ID path.
TComponent::getApplication()
TComponent::getChild()
TComponent::getChildren()
TComponent::getDefinition()
Returns or builds a component definition.
TComponent::getGlobalization()
Returns the Globalization instance for the application.
TComponent::getID()
TComponent::getModule()
Returns the module object that contains the component or the page containing the component.
TComponent::getPage()
TComponent::getParent()
TComponent::getPropertyInitValue()
Gets the initial value of a property.
TComponent::getPropertyType()
Returns the type of a property
TComponent::getRequest()
Returns the request object associated with application.
TComponent::getServiceManager()
Returns the service manager for this application.
TComponent::getSession()
Returns the session object associated with the application.
TComponent::getSessionState()
Returns a session variable.
TComponent::getUniqueID()
Returns the unique ID of the component.
TComponent::getUser()
Returns the user object associated with the application.
TComponent::hasChildren()
TComponent::hasEvent()
Determines whether an event is defined.
TComponent::hasProperty()
Determines whether a property is defined.
TComponent::initProperties()
Initializes the property values.
TComponent::instantiateTemplate()
Parses a template string and instantiates the content.
TComponent::onDataBinding()
This method is invoked when dataBind is invoked for the component.
TComponent::raiseEvent()
Invokes all attached event handler functions for a particular event.
TComponent::removeChild()
Removes a child component.
TComponent::removeChildren()
Removes all child components.
TComponent::setAttribute()
Sets an attribute.
TComponent::setDefinition()
Sets a component definition.
TComponent::setID()
Sets a component ID.
TComponent::setParent()
Sets the parent of this component.
TComponent::setPropertyInitValue()
Sets the initial value of a property.
TComponent::setRoot()
Sets the root component in the component hierarchy.
TComponent::setSessionState()
Sets a session variable.
TComponent::unbindProperty()
Breaks the binding between a property and an expression.
TComponent::__get()
Returns a property value by name or a child component by ID.
TComponent::__set()
Sets value of a component property.

Class Methods


method close [line 340]

void close( )

Closes the DB connection.

You are not required to call this method as PHP will automatically to close any DB connections when exiting a script.




access:  public


[ Top ]

method getCacheDir [line 262]

string getCacheDir( )



return:  the cache directory for adodb module
access:  public


[ Top ]

method getDatabase [line 228]

string getDatabase( )



return:  the database name
access:  public


[ Top ]

method getDataSourceName [line 139]

string getDataSourceName( )



return:  the data source name (DSN)
access:  public


[ Top ]

method getDriver [line 160]

string getDriver( )



return:  the DB driver (mysql, sqlite, etc.)
access:  public


[ Top ]

method getFetchMode [line 280]

string getFetchMode( )



return:  fetch mode of query data
access:  public


[ Top ]

method getHost [line 177]

string getHost( )



return:  the DB host name/IP (and port number) in the format "host[:port]"
access:  public


[ Top ]

method getPassword [line 211]

string getPassword( )



return:  the DB password
access:  public


[ Top ]

method getUsername [line 194]

string getUsername( )



return:  the DB username
access:  public


[ Top ]

method isPersistentConnection [line 245]

boolean isPersistentConnection( )



return:  whether the DB connection is persistent
access:  public


[ Top ]

method open [line 303]

void open( )

Establishes a DB connection.

An ADOConnection instance will be created if none. The data fetch mode is also set here.




access:  public


[ Top ]

method setCacheDir [line 272]

void setCacheDir( string $value)

Sets the cache directory for ADODB (in adodb it is

called to $ADODB_CACHE_DIR)




access:  public


Parameters:

string   $value   the cache directory for adodb module

[ Top ]

method setDatabase [line 237]

void setDatabase( string $value)

Sets the database name



access:  public


Parameters:

string   $value   the database name

[ Top ]

method setDataSourceName [line 152]

void setDataSourceName( string $value)

Sets the data source name (DSN).

The format of DSN is: $driver://$username:$password@hostname/$database?options[=value] Note, each part if it contains special characters you need to rawurlencode it first.




access:  public


Parameters:

string   $value   the data source name (DSN)

[ Top ]

method setDriver [line 169]

void setDriver( string $value)

Sets the DB driver (mysql, sqlite, etc.)



access:  public


Parameters:

string   $value   the DB driver

[ Top ]

method setFetchMode [line 289]

void setFetchMode( string $value)

Sets the fetch mode of query data: Associative, Numeric, Both, Default (default)



access:  public


Parameters:

string   $value   the fetch mode of query data

[ Top ]

method setHost [line 186]

void setHost( string $value)

Sets the DB host name/IP (and port number) in the format "host[:port]"



access:  public


Parameters:

string   $value   the DB host

[ Top ]

method setPassword [line 220]

void setPassword( string $value)

Sets the DB password



access:  public


Parameters:

string   $value   the DB password

[ Top ]

method setPersistentConnection [line 254]

void setPersistentConnection( boolean $value)

Sets whether the DB connection should be persistent



access:  public


Parameters:

boolean   $value   whether the DB connection should be persistent

[ Top ]

method setUsername [line 203]

void setUsername( string $value)

Sets the DB username



access:  public


Parameters:

string   $value   the DB username

[ Top ]

method __call [line 110]

void __call( mixed $method, mixed $params, mixed 2)

PHP magic function.

This method will pass all method calls to ADOConnection class provided in the ADODB library.




access:  public


Parameters:

mixed   2   return value of the method call
mixed   $method   method name
mixed   $params   method call parameters

[ Top ]

method __sleep [line 122]

array __sleep( )

Cleanup work before serializing.

This is a PHP defined magic method.




return:  the names of instance-variables to serialize.
access:  public


[ Top ]

method __wakeup [line 132]

void __wakeup( )

This method will be automatically called when unserialization happens.

This is a PHP defined magic method.




access:  public


[ Top ]


Class Constants

FETCH_ASSOCIATIVE = 'Associative'

[line 87]


[ Top ]

FETCH_BOTH = 'Both'

[line 89]


[ Top ]

FETCH_DEFAULT = 'Default'

[line 90]


[ Top ]

FETCH_NUMERIC = 'Numeric'

[line 88]


[ Top ]



© 2004-2005 PRADO Software Group. All Rights Reserved.