I've got PHP installed from the repos on my Ubuntu 9.10 local machine. Where can I find the source code to the PDO classes?
If you don't do this explicitly, PHP will automatically close the connection when your script ends. So the answer is no, you don't need to do anything unless you need to explicitly close the connection during the script execution for whatever reason, in which case just set your PDO object to null.
The connection remains active for the lifetime of that PDO object. To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted—you do this by assigning null to the variable that holds the object.
PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is not an abstraction layer like PearDB.
Fetch data from a result set by calling one of the following fetch methods: To return a single row from a result set as an array or object, call the PDOStatement::fetch method. To return all of the rows from the result set as an array of arrays or objects, call the PDOStatement::fetchAll method.
As of PHP 5.1, PDO is part of the PHP core so it should be somewhere in there. My educated guess is
/ext/pdo
Before 5.1, it used to be a PECL package that is still available here. If you want to browse the source just for curiosity, it might do. If you need the current one, look in the core.
The PHP code can be found on GitHub: https://github.com/php/php-src
And the PDO classes are under /ext/pdo
as Pekka 웃 pointed out.
In this way you don't need to download the full code, but read it online.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With