$e->getMessage();
}
$result = $pdo->query("select * from users");
foreach ($result as $row)
echo $row['name'];
?>
We just changed the DSN here.
DSN Settings for Different Databases Engines
Let us take a look at the DSN settings for different database engines to connect
with PDO. Supported database drivers are as shown below:
PDO_DBLIB for FreeTDS/Microsoft SQL Server/Sybase
PDO_FIREBIRD for Firebird/Interbase 6
PDO_INFORMIX for IBM Informix Dynamic Server
PDO_MYSQL for MySQL 3.x/4.x/5.x
PDO_OCI for Oracle Call Interface
PDO_ODBC for ODBC v3 (IBM DB2, unixODBC and win32 ODBC)
PDO_PGSQL for PostgreSQL
PDO_SQLITE for SQLite 3 and SQLite 2
??? ??? ??? ??? ??? ??? ??? ???
Chapter 7
[ 179 ]
Let's have a look at these sample driver-specific DSN settings:
mssql:host=localhost;dbname=testdb
sybase:host=localhost;dbname=testdb
dblib:host=localhost;dbname=testdb
firebird:User=john;Password=mypass;Database=DATABASE.GDE;
DataSource=localhost;Port=3050
informix:host=host.domain.com; service=9800;database=common_db;
server=ids_server; protocol=onsoctcp;EnableScrollableCursors=1
mysql:host=localhost;port=3307;dbname=testdb
mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
oci:mydb
oci:dbname=//localhost:1521/mydb
odbc:testdb
odbc:DRIVER={IBM DB2 ODBC
DRIVER};HOSTNAME=localhost;PORT=50000;DATABASE=SAMPLE;PROTOCOL=TCPIP;
UID=db2inst1;PWD=ibmdb2;
odbc:Driver={Microsoft Access Driver
(*.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193