Installing the PDO module for PHP5.0.3 under Debian

Source: Internet
Author: User

PDO as the next PHP database unified interface, the current version is 0.9, it seems soon to release, early adopters.
After testing, PDO coupling is about 3 times times faster than ADODB, and the direct connection is very small.
Test tool: AB
Test conditions apache/2.0.54 (Debian gnu/linux) mod_fastcgi/2.4.2 php/5.0.4-0.10 mod_perl/2.0.1 perl/v5.8.7 Server at 127.0.0.1 Port 80
Database: postgres8.0.3
Hardware: c4-1.7g;384m
Installing PDO requires PHP's development kit and gcc\g++, and of course PHP's Php5-dev
Install Pdo_pgsql need Libpg-dev above software must apt-get otherwise will fail!!!
#>pear Remote-info PDO
Pear Remote-info PDO

notice:undefined Index:name in remote.php on line 132

notice:undefined index:version in remote.php on line 133

notice:undefined Index:name in cli.php on line 443

notice:undefined Index:license in cli.php on line 444

notice:undefined index:category in cli.php on line 445

notice:undefined index:summary in cli.php on line 446

notice:undefined index:description in cli.php on line 447
Package Details:
================
Latest
Installed-no-
Package
License
Category
Summary
Description
Ha, still do not know version good, to http://pecl.php.net/search, current version 0.9
Ok
# "Pear Install pdo-0.9
Pear will install it for you.
The compiled modules are placed in the following:/usr/lib/php5/20041030/directory
#>cd/usr/lib/php5/20041030/
Note: The PHP external module of the Debian system requires two files to be started, and one is the pdo.so we just compiled
Also require a pdo.info file
If you don't write it, fry the following:
Package= "PDO"
Extname= "PDO"
Dsoname= "PDO"
sapilist= "Apache apache2 CGI CLI fcgi"
Depends= ""
Priority= "500"
Architecture= "any"
Then run:
# "/usr/sbin/php5-modconf apache2
The system will prompt you for which modules you need, check PDO to determine
The PDO is installed successfully.
Install pdo_pgsql-0.9 below
This needs to be done as follows:
# "Pear Download pdo_pgsql-0.9
#> Tar zxf pdo_pgsql-0.9.tgz
#>cd pdo_pgsql-0.9
#>phpize
#>./configure
#>make
#>make Install
Then repeat the process of installing PDO above: Modify Pdo_pgsql.info
Package= "Pdo_pgsql"
Extname= "Pdo_pgsql"
Dsoname= "Pdo_pgsql"
sapilist= "Apache apache2 CGI CLI fcgi"
Depends= ""
Priority= "500"
Architecture= "any"
Run
# "/usr/sbin/php5-modconf apache2
Select the Pdo_pgsql module
OK, everything's ready.
# "Apache2-k Restart
To edit a test module:

Connect to an ODBC database using driver invocation

$host = ' xxxx.xxxx.com ';
$port = ' 5433 ';
$dbname = ' Test ';
$user = ' xxxxxx ';
$passWord = ' xxxxxxxx ';
$CC = "host= $host, Dbname= $dbname, port= $port";
$DSN = "pgsql:host= $host port= $port dbname= $dbname user= $user password= $password";


try {
$DBH = new PDO ($DSN, $user, $password);
} catch (Pdoexception $e) {
Echo ' Connection failed: '. $e->getmessage ();
}

$sql = ' select * from CPJCSJ ';
foreach ($dbh->query ($sql) as $row) {
Print $row [' CPDM ']. " \ t ";
Print $row [' CPDH ']. "\ t";
Print $row [' CPMC ']. "\ n";
}

?>

OK, enter http://localhost/pdotest.php on your browser.
Did you see the data in your database?
Congratulations to you!!!

  • 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.