Download the PHP package tebe/pdo without Composer
On this page you can find all versions of the php package tebe/pdo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package pdo
Short Description Provides an extension to the native PDO along with additional functionality.
License MIT
Homepage https://github.com/tebe/pdo
Informations about the package pdo
tebe\pdo
Provides an extension to the native PDO along with additional functionality.
tebe\pdo
is an extension of the native PDO in the style of a thin wrapper. All constants, properties and methods of the underlying PDO classes are therefore available. Code already using or typehinted to the native PDO can use tebe\pdo
with minimal changes for the most part.
Added or changed functionality in tebe\pdo
over the native PDO includes:
- Exceptions by default.
tebe\pdo
starts in the ERRMODE_EXCEPTION mode for error reporting instead of the ERRMODE_SILENT mode. - New
PDO::run()
method. This is for convenience to prepare and execute an SQL statement in one step. - Bind array of values to placeholder in
PDO::run()
method. Placeholders that represent array values will be replaced with comma-separated quoted values. This means you can bind an array of values to a placeholder used with an IN (...) condition. - Array quoting. The
PDO::quote()
method will accept an array as input, and return a string of comma-separated quoted values. - New
PDOStatement::fetch*()
methods. The new methods provide for commonly-used fetch actions. - New
PDOStatement::fetchAll*()
methods. The new methods provide for commonly-used fetch all actions.
Examples
Create a PDO instance representing a connection to a database.
Execute an SQL statement without placeholders and return the number of affected rows.
Prepare and execute an SQL statement without placeholders, and fetch all rows from the result set.
Prepare a statement with placeholders for execution, return a statement object, and fetch all columns from the result set.
Run a query with placeholders, return the resulting PDOStatement, and fetch key value array (pairs) from the result set.
Run a query with an IN clause and placeholders, return the resulting PDOStatement, and fetch all rows grouped by color from the result set.
Quote an array for use in a query.
Installation and Autoloading
This package is installable and PSR-4 autoloadable via Composer as tebe/pdo
.
Alternatively, download a release, or clone this repository, then include the classes manually:
Dependencies
This package requires PHP 8.1 or later; it has been tested on latest Linux, macOS and Windows on PHP 8.1-8.4. We recommend using the latest available version of PHP as a matter of principle. tebe\pdo
doesn't depend on other external packages.
Documentation
tebe\pdo\PDO
The class tebe\pdo\PDO
is a wrapper for the native PDO
class and implements all methods of this class.
The main differences are that some methods return tebe\pdo\PDOStatement
instances and the quote
method can also handle arrays.
In addition, the class contains a new method run
, which executes a query with bound values and returns the resulting statement instance.
getWrappedPdo
Returns the underlying PDO instance.
prepare
Prepares a statement for execution and returns a statement object.
This differs from PDO::prepare
in that it will return a tebe\pdo\PDOStatement
object.
See php.net
query
Prepares and executes an SQL statement without placeholders.
This differs from PDO::query
in that it will return a tebe\pdo\PDOStatement
object.
See php.net
quote
Quotes a string for use in a query.
This differs from PDO::quote
in that it will convert an array into a string of comma-separated quoted values.
See php.net
run
Runs a query with bound values and returns the resulting tebe\pdo\PDOStatement
.
Array values will be processed by the parser instance and placeholders are replaced.
The remaining tebe\pdo\PDO
methods are simple wrapper methods of the underlying PDO
class.
For more information, see php.net.
- beginTransaction
- commit
- __construct
- errorCode
- errorInfo
- exec
- getAttribute
- getAvailableDrivers
- inTransaction
- lastInsertId
- rollBack
- setAttribute
tebe\pdo\PDOStatement
The class tebe\pdo\PDOStatement
is a wrapper for the native PDOStatement
class and implements all methods of this class.
The main difference is that the execute
method returns a statement instance. This was done to allow method chaining aka fluent interface.
Besides that it contains several new fetch*()
and fetchAll*()
methodes for commonly-used fetch actions.
__construct
Creates a tebe\pdo\PDOStatement
instance representing a query statement and wraps the original PDOStatement
.
execute
Executes a prepared statement
This differs from PDOStatement::execute
in that it will return a tebe\pdo\PDOStatement
object.
See php.net
fetchAffected
Fetches the number of affected rows from the result set.
fetchAssoc
Fetches the next row from the result set as an associative array.
fetchBoth
Fetches the next row from the result set as an associative and indexed array.
fetchInto
Fetches the next row from the result as the updated passed object, by mapping the columns to named properties of the object.
fetchNamed
Fetches the next row from the result set as an associative array; If the result set contains multiple columns with the same name, an array of values per column name is returned.
fetchNumeric
Fetches the next row from the result set as an indexed array.
fetchPair
Fetches the next row from the result set as a key-value pair.
fetchAllAssoc
Fetches all rows from the result set as an array of associative arrays.
fetchAllBoth
Fetches all rows from the result set as an array of associative and indexed arrays.
fetchAllColumn
Fetches all rows from the result set as an array of a single column.
fetchAllFunction
Fetches all rows from the result set as an array by calling a function for each row.
fetchAllGroup
Fetches all rows from the result set as an array by grouping all rows by a single column.
fetchAllNamed
Fetches all rows from the result set as an array of associative arrays; If the result set contains multiple columns with the same name, an array of values per column name is returned.
fetchAllNumeric
Fetches all rows from the result set as an array of indexed arrays.
fetchAllObject
Fetches all rows from the result set as an array of objects of the requested class, mapping the columns to named properties in the class.
fetchAllPair
Fetches all rows from the result set as an array of key-value pairs.
fetchAllUnique
Fetches all rows from the result set as an array of arrays, indexed by an unique field.
The remaining tebe\pdo\PDOStatement
methods are simple wrapper methods of the underlying PDOStatement
class.
For more information, see php.net.
- bindColumn
- bindParam
- bindValue
- closeCursor
- columnCount
- debugDumpParams
- errorCode
- errorInfo
- fetch
- fetchAll
- fetchColumn
- fetchObject
- getAttribute
- getColumnMeta
- getIterator
- nextRowset
- rowCount
- setAttribute
- setFetchMode
tebe\pdo\PDOParser
Class tebe\pdo\PDOParser
offers parsing and rebuilding functions for all drivers.
__construct
Creates a tebe\pdo\PDOParser
instance.
rebuild
Rebuilds a statement with placeholders and bound values.
Quality
This project adheres to Semantic Versioning.
To run the functional tests at the command line, issue composer install
and then composer test
at the package root. (This requires Composer to be available as composer
.)
This package attempts to comply with PSR-1, PSR-4, and PSR-12. If you notice compliance oversights, please send a patch via pull request.
All versions of pdo with dependencies
ext-pdo Version *