53 |
Changes in database support
54 |
70 |
PDO overview
71 |
72 | PHP Data Objects (PDO) were introduced as a
73 | PECL extension under PHP 5.0, and became part of the core PHP distribution
74 | in PHP 5.1.x. The PDO extension provides a consistent interface for database
75 | access, and is used alongside database-specific PDO drivers. Each driver
76 | may also have database-specific functions of its own, but basic data
77 | access functionality such as issuing queries and fetching data is covered
78 | by PDO functions, using the driver named in
79 | PDO::__construct().
80 |
81 |
82 | Note that the PDO extension, and its drivers, are intended to be built as
83 | shared extensions. This will enable straightforward driver upgrades from
84 | PECL, without forcing you to rebuild all of PHP.
85 |
86 |
87 | At the point of the PHP 5.1.x release, PDO is more than ready for widespread
88 | testing and could be adopted in most situations. However, it is important
89 | to understand that PDO and its drivers are comparatively young and may be
90 | missing certain database-specific features; evaluate PDO carefully before
91 | you use it in new projects.
92 |
93 |
94 | Legacy code will generally rely on the pre-existing database extensions,
95 | which are still maintained.
96 |
97 |
98 |
99 |
100 |
Changes in MySQL support
101 |
102 | In PHP 4, MySQL 3 support was built-in. With the release of PHP 5.0 there
103 | were two MySQL extensions, named 'mysql' and 'mysqli', which were designed
104 | to support MySQL < 4.1 and MySQL 4.1 and up, respectively. With the
105 | introduction of PDO, which provides a very fast interface to all the
106 | database APIs supported by PHP, the PDO_MYSQL driver can support any of
107 | the current versions (MySQL 3, 4 or 5) in PHP code written for PDO,
108 | depending on the MySQL library version used during compilation. The older
109 | MySQL extensions remain in place for reasons of back compatibility, but
110 | are not enabled by default.
111 |
112 |
113 |
114 |
115 |
Changes in SQLite support
116 |
117 | In PHP 5.0.x, SQLite 2 support was provided by the built-in sqlite
118 | extension, which was also available as a PECL extension in PHP 4.3 and PHP
119 | 4.4. With the introduction of PDO, the sqlite extension doubles up to act
120 | as a 'sqlite2' driver for PDO; it is due to this that the sqlite extension
121 | in PHP 5.1.x has a dependency upon the PDO extension.
122 |
123 |
124 | PHP 5.1.x ships with a number of alternative interfaces to sqlite:
125 |
126 |
127 | The sqlite extension provides the "classic" sqlite procedural/OO API that
128 | you may have used in prior versions of PHP. It also provides the PDO
129 | 'sqlite2' driver, which allows you to access legacy SQLite 2 databases
130 | using the PDO API.
131 |
132 |
133 | PDO_SQLITE provides the 'sqlite' version 3 driver. SQLite version 3 is
134 | vastly superior to SQLite version 2, but the file formats of the two
135 | versions are not compatible.
136 |
137 |
138 | If your SQLite-based project is already written and working against
139 | earlier PHP versions, then you can continue to use ext/sqlite without
140 | problems, but will need to explicitly enable both PDO and sqlite. New
141 | projects should use PDO and the 'sqlite' (version 3) driver, as this is
142 | faster than SQLite 2, has improved locking concurrency, and supports both
143 | prepared statements and binary columns natively.
144 |
145 |
146 | You must enable PDO to use the SQLite extension. If you want to build the
147 | PDO extension as a shared extension, then the SQLite extension must also
148 | be built shared. The same holds true for any extension that provides a PDO
149 | driver
150 |
151 |
152 |