phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


ADOdb: Connection Statement

Tag: adodb, database, database layer   Category: PHP Database
post: 29 Oct 2007 read: 2,545


In this tutorial, we discuss more deep about connection in php adodb. There are 2 connection in adodb: Connect() and PConnect().

Connect($host,[$user],[$password],[$database]) We have used in our practice in adodb introduction. Non-persistent connect to data source or server $host, using userid $user and password $password. If the server supports multiple databases, connect to database $database.

The code like this:


    $db = ADONewConnection($databasetype); 
    $db->debug = true; 
    $db->Connect($server, $user, $password, $database); 

If you are using a Microsoft ADO and not OLEDB, you can set the $database parameter to the OLEDB data provider you are using.

PConnect($host,[$user],[$password],[$database]) Persistent connect to data source or server $host, using userid $user and password $password. If the server supports multiple databases, connect to database $database.


include('adodb.inc.php'); # load code common to ADOdb 
    $conn = &ADONewConnection('access'); # create a connection 
    $conn->PConnect('northwind'); # connect to MS-Access, northwind DSN 

If you confuse pconnect() and connect(), below may be usefull:

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (ex, mysql_close() will not close links established by (ex, mysql_pconnect())).



Series this article:
ADOdb: Introduction
ADOdb: Connection Statement
ADOdb: Advance Select Statement
ADOdb: How to show tables
ADOdb: How to show fields
ADOdb: How to show databases
ADOdb: Caching of Recordset
ADOdb: Recordset to HTML
ADOdb: Multi Database Connection
ADOdb: Data Dictionary
ADOdb: Quick Export Data
ADOdb: Insert data style
ADOdb: Replace Data
ADOdb: Log Query
PHP ADOdb: Understanding Pivot Table For Reporting
PHP ADOdb: Creating Pivot Table
PHP ADOdb: Creating Query to Build Pivot Table

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting