SlideShare a Scribd company logo
1 of 17
PHP With the New PDO::Informix
Presented by: Thomas Beebe
Advanced DataTools Corporation
tom@advancedatatools.com
What is PHP
●
PHP stands for “PHP: Hypertext Preprocessor”
●
Started in 1995 by Rasmus Lerdorf as perl scripts
●
Andi Gutmans and Zeev Suraski launched PHP3 in 1997
to replace the dated PHP/FI
●
1998 – PHP 4
●
2004 – PHP 5
●
Provides a very flexible, expendable application
development environment, free to use for any purpose.
●
Large collection of modules and extensions available
(mostly free of charge)
PEAR
●
"PHP Extension and Application Repository"
●
Package management for PHP
●
Offers standards for creating packages for PHP
PECL
●
“PHP Extension Community Library”
●
Offers a hosting repository of any and all php
extensions, as well as hosting and support for
development.
●
pdo drivers are provided through pecl.
Why PDO
●
Standardized code and connection methods
●
ODBC can be troublesome
●
The ifx_ driver is not overly stable and is buggy
●
Open source development methodology
●
IBM support pdo_informix driver
●
Proper error handling
Demo 1
Installing
●
Two ways to install:
– extensions (php.ini)
– compiled in (/tmp/php-x.x.x/ext/pdo_informix)
Compiling into PHP
●
Download the latest pdo_informix driver
●
Extract it to php_source/ext [it will be
PDO_INFORMIX-1.0.x]
●
Rename it to pdo_informix
●
cd ..
●
./buildconf –force [this will rebuild configure]
●
./configure –help | grep informix (make sure it is
there)
●
./configure –args --with-pdo-
informix=$INFORMIXDIR
Connection Paramaters●
$dbh->setAttribute($ATTR,$VALUE);
●
PDO::ATTR_CASE:
– PDO::CASE_LOWER
– PDO::CASE_UPPER
– PDO::CASE_NATURAL
●
PDO::ATTR_ERRMODE:
– PDO::ERRMODE_SILENT
– PDO::ERRMODE_WARNING
– PDO::ERRMODE_EXCEPTION
●
PDO::ATTR_STRINGIFY_FETCHES
●
PDO::ATTR_ORACLE_NULLS
Demo 2
Binding Paramaters
●
Safer, faster, often easier to manage.
●
Insertions use bindParam();
●
Selects use bindColumn
●
Insertions:
– $name = “Joe Smith”;
– $stmt=$dbh->prepare(“insert into tab_a (name) values
(?)”);
– $stmt->bindParam(1, $name);
– $stmt->execute();
– $name = “John Jones”;
– $stmt->bindParam(1, $name);
– $stmt->execute();
Named Bind
●
This tends to be easier to maintain for large
inserts/updates.
●
$stmt = $dbh->prepare(“insert into test (name)
values (:name)”);
●
$name = “Papa Smurf”;
●
$stmt->bindParam(':name', $name);
●
$stmt->execute();
●
$name = “Bubba Jones”;
Binding on Selects
●
This is required for reading blobs from the
database
●
$stmt = $db->prepare("select cat_desc from
catalog”);
●
$stmt->execute();
●
$stmt->bindColumn(1, $lob,
PDO::PARAM_STR);
●
$stmt->fetch(PDO::FETCH_BOUND);
Binding Paramaters
●
LOB needs to be specified, the others are optional
but can help maintain proper data types
●
PDO::PARAM_LOB – Data Blobs
●
PDO::PARAM_STR – Char/Varchar/Text
●
PDO::PARAM_BOOL – Bool
●
PDO::PARAM_INT - Integer
Error Handling
●
PHP 5 introduced try/catch which can be a
lifesaver.
●
try { sql stuff here...
●
} catch (PDOException $e) {
●
print "Error!: " . $e->getMessage() . "<br/>";
●
die();
●
}
Error Handling (cont)
●
$dbh->errorInfo();
– Returns an array of the last statement executed
– 0: Sqlstate Error Code
– 1: Driver specific error number
– 2: Driver error message
●
Exception handling variable commands
– $e->getMessage() = Error message
– $e->getLine() = Line Number
– $e->getFile() = File that caused the error
– $e->getCode() = Code the caused the error
– $e->getTrace() = Array of the error trace
Questions?
Thomas Beebe
Advanced DataTools Corporation
tom@advancedatatools.com

More Related Content

What's hot

Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSDavid Nguyen
 
.htaccess Cheatsheet
.htaccess Cheatsheet.htaccess Cheatsheet
.htaccess CheatsheetShankar Soma
 
02 Installing and configuring PHP environment & PhpStorm #burningkeyboards
02 Installing and configuring PHP environment & PhpStorm #burningkeyboards02 Installing and configuring PHP environment & PhpStorm #burningkeyboards
02 Installing and configuring PHP environment & PhpStorm #burningkeyboardsDenis Ristic
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentPôle Systematic Paris-Region
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증박 민규
 
Redis -- Memory as the New Disk
Redis -- Memory as the New DiskRedis -- Memory as the New Disk
Redis -- Memory as the New DiskTim Lossen
 
New kid on the block node.js
New kid on the block node.jsNew kid on the block node.js
New kid on the block node.jsJoel Divekar
 
Ansible vault - Introductory session
Ansible vault - Introductory session Ansible vault - Introductory session
Ansible vault - Introductory session Buvanesh Kumar
 
PHP - Getting good with cookies
PHP - Getting good with cookiesPHP - Getting good with cookies
PHP - Getting good with cookiesFirdaus Adib
 
Macros code for Protecting and Unprotecting Sheets
Macros code for Protecting and Unprotecting SheetsMacros code for Protecting and Unprotecting Sheets
Macros code for Protecting and Unprotecting SheetsPramodkumar Jha
 
Python-specific packaging
Python-specific packagingPython-specific packaging
Python-specific packagingdwvisser
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Yuriko IKEDA
 
Building High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformBuilding High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformWade Wegner
 
ClusterDesktop how-to autostart on Mac
ClusterDesktop how-to autostart on MacClusterDesktop how-to autostart on Mac
ClusterDesktop how-to autostart on MacEmil Parashkevov
 

What's hot (20)

Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJS
 
.htaccess Cheatsheet
.htaccess Cheatsheet.htaccess Cheatsheet
.htaccess Cheatsheet
 
02 Installing and configuring PHP environment & PhpStorm #burningkeyboards
02 Installing and configuring PHP environment & PhpStorm #burningkeyboards02 Installing and configuring PHP environment & PhpStorm #burningkeyboards
02 Installing and configuring PHP environment & PhpStorm #burningkeyboards
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증
 
Php Basics part 1
Php Basics part 1Php Basics part 1
Php Basics part 1
 
Redis -- Memory as the New Disk
Redis -- Memory as the New DiskRedis -- Memory as the New Disk
Redis -- Memory as the New Disk
 
New kid on the block node.js
New kid on the block node.jsNew kid on the block node.js
New kid on the block node.js
 
Ansible vault - Introductory session
Ansible vault - Introductory session Ansible vault - Introductory session
Ansible vault - Introductory session
 
Message Decrypt
Message DecryptMessage Decrypt
Message Decrypt
 
PHP - Getting good with cookies
PHP - Getting good with cookiesPHP - Getting good with cookies
PHP - Getting good with cookies
 
Macros code for Protecting and Unprotecting Sheets
Macros code for Protecting and Unprotecting SheetsMacros code for Protecting and Unprotecting Sheets
Macros code for Protecting and Unprotecting Sheets
 
Python-specific packaging
Python-specific packagingPython-specific packaging
Python-specific packaging
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境
 
35 request
35 request35 request
35 request
 
Solaris mysql sop
Solaris mysql sopSolaris mysql sop
Solaris mysql sop
 
Banquet 05
Banquet 05Banquet 05
Banquet 05
 
Building High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure PlatformBuilding High Performance Web Applications with the Windows Azure Platform
Building High Performance Web Applications with the Windows Azure Platform
 
ClusterDesktop how-to autostart on Mac
ClusterDesktop how-to autostart on MacClusterDesktop how-to autostart on Mac
ClusterDesktop how-to autostart on Mac
 
Linux Security with SElinux
Linux Security with SElinuxLinux Security with SElinux
Linux Security with SElinux
 

Viewers also liked

Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...webhostingguy
 
Managing Clients' Mission Critical Applications
Managing Clients' Mission Critical ApplicationsManaging Clients' Mission Critical Applications
Managing Clients' Mission Critical Applicationswebhostingguy
 

Viewers also liked (7)

Security.ppt
Security.pptSecurity.ppt
Security.ppt
 
Space Review.ppt
Space Review.pptSpace Review.ppt
Space Review.ppt
 
Seasons
SeasonsSeasons
Seasons
 
ZendCon 08 php 5.3
ZendCon 08 php 5.3ZendCon 08 php 5.3
ZendCon 08 php 5.3
 
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
 
Managing Clients' Mission Critical Applications
Managing Clients' Mission Critical ApplicationsManaging Clients' Mission Critical Applications
Managing Clients' Mission Critical Applications
 
Presentation
PresentationPresentation
Presentation
 

Similar to download presentation

Speed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PGSpeed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PGMarcus Sá
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objectswebhostingguy
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Francisco José Seva Mora
 
PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013rjsmelo
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会Ippei Ogiwara
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from githubAntony Gitomeh
 
Getting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshopGetting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshopstefansayer
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet systemrkhatibi
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet SystemPuppet
 
Cutting Back Processing Time
Cutting Back Processing TimeCutting Back Processing Time
Cutting Back Processing TimeHenrique Moody
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetPuppet
 
Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxssuser020436
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best PracticesAnsar Ahmed
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best PracticesAnsar Ahmed
 

Similar to download presentation (20)

Speed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PGSpeed up your development environment PHP + Nginx + Fedora + PG
Speed up your development environment PHP + Nginx + Fedora + PG
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objects
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
 
Odoo V8 Installation
Odoo V8 InstallationOdoo V8 Installation
Odoo V8 Installation
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
 
PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
 
Getting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshopGetting started with SIP Express Media Server SIP app server and SBC - workshop
Getting started with SIP Express Media Server SIP app server and SBC - workshop
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 
It gilde 20150209
It gilde 20150209It gilde 20150209
It gilde 20150209
 
Linux Hardening - Made Easy
Linux Hardening - Made EasyLinux Hardening - Made Easy
Linux Hardening - Made Easy
 
Cutting Back Processing Time
Cutting Back Processing TimeCutting Back Processing Time
Cutting Back Processing Time
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptx
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 

More from webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guidewebhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serverswebhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidationwebhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructurewebhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.pptwebhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandiserswebhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Productswebhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mbwebhostingguy
 

More from webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

download presentation

  • 1. PHP With the New PDO::Informix Presented by: Thomas Beebe Advanced DataTools Corporation tom@advancedatatools.com
  • 2. What is PHP ● PHP stands for “PHP: Hypertext Preprocessor” ● Started in 1995 by Rasmus Lerdorf as perl scripts ● Andi Gutmans and Zeev Suraski launched PHP3 in 1997 to replace the dated PHP/FI ● 1998 – PHP 4 ● 2004 – PHP 5 ● Provides a very flexible, expendable application development environment, free to use for any purpose. ● Large collection of modules and extensions available (mostly free of charge)
  • 3. PEAR ● "PHP Extension and Application Repository" ● Package management for PHP ● Offers standards for creating packages for PHP
  • 4. PECL ● “PHP Extension Community Library” ● Offers a hosting repository of any and all php extensions, as well as hosting and support for development. ● pdo drivers are provided through pecl.
  • 5. Why PDO ● Standardized code and connection methods ● ODBC can be troublesome ● The ifx_ driver is not overly stable and is buggy ● Open source development methodology ● IBM support pdo_informix driver ● Proper error handling
  • 7. Installing ● Two ways to install: – extensions (php.ini) – compiled in (/tmp/php-x.x.x/ext/pdo_informix)
  • 8. Compiling into PHP ● Download the latest pdo_informix driver ● Extract it to php_source/ext [it will be PDO_INFORMIX-1.0.x] ● Rename it to pdo_informix ● cd .. ● ./buildconf –force [this will rebuild configure] ● ./configure –help | grep informix (make sure it is there) ● ./configure –args --with-pdo- informix=$INFORMIXDIR
  • 9. Connection Paramaters● $dbh->setAttribute($ATTR,$VALUE); ● PDO::ATTR_CASE: – PDO::CASE_LOWER – PDO::CASE_UPPER – PDO::CASE_NATURAL ● PDO::ATTR_ERRMODE: – PDO::ERRMODE_SILENT – PDO::ERRMODE_WARNING – PDO::ERRMODE_EXCEPTION ● PDO::ATTR_STRINGIFY_FETCHES ● PDO::ATTR_ORACLE_NULLS
  • 11. Binding Paramaters ● Safer, faster, often easier to manage. ● Insertions use bindParam(); ● Selects use bindColumn ● Insertions: – $name = “Joe Smith”; – $stmt=$dbh->prepare(“insert into tab_a (name) values (?)”); – $stmt->bindParam(1, $name); – $stmt->execute(); – $name = “John Jones”; – $stmt->bindParam(1, $name); – $stmt->execute();
  • 12. Named Bind ● This tends to be easier to maintain for large inserts/updates. ● $stmt = $dbh->prepare(“insert into test (name) values (:name)”); ● $name = “Papa Smurf”; ● $stmt->bindParam(':name', $name); ● $stmt->execute(); ● $name = “Bubba Jones”;
  • 13. Binding on Selects ● This is required for reading blobs from the database ● $stmt = $db->prepare("select cat_desc from catalog”); ● $stmt->execute(); ● $stmt->bindColumn(1, $lob, PDO::PARAM_STR); ● $stmt->fetch(PDO::FETCH_BOUND);
  • 14. Binding Paramaters ● LOB needs to be specified, the others are optional but can help maintain proper data types ● PDO::PARAM_LOB – Data Blobs ● PDO::PARAM_STR – Char/Varchar/Text ● PDO::PARAM_BOOL – Bool ● PDO::PARAM_INT - Integer
  • 15. Error Handling ● PHP 5 introduced try/catch which can be a lifesaver. ● try { sql stuff here... ● } catch (PDOException $e) { ● print "Error!: " . $e->getMessage() . "<br/>"; ● die(); ● }
  • 16. Error Handling (cont) ● $dbh->errorInfo(); – Returns an array of the last statement executed – 0: Sqlstate Error Code – 1: Driver specific error number – 2: Driver error message ● Exception handling variable commands – $e->getMessage() = Error message – $e->getLine() = Line Number – $e->getFile() = File that caused the error – $e->getCode() = Code the caused the error – $e->getTrace() = Array of the error trace
  • 17. Questions? Thomas Beebe Advanced DataTools Corporation tom@advancedatatools.com