Download the PHP package jinya/pdox without Composer
On this page you can find all versions of the php package jinya/pdox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package pdox
Short Description Jinya PDOx is a simple object mapper built around PHPs standard PDO
License MIT
Informations about the package pdox
permalink: index.html layout: "default"
PDOx
PDOx is a small PDO extension that enables developers to simple run a single query to map a table to the desired object. For this purpose it utilizes either native PDO or laminas-hydrator.
Installation
Simply run composer require jinya/pdox
in your project.
Usage
PDOx contains three methods apart from the default PDO methods.
$pdo->fetchObject($query, $prototype, $parameters, $strategies)
This method allows you to fetch one single object from the query and hydrate the result into a class of the type
of $prototype
. An example call can look like this:
The code above is really simple, as first parameter you give it the query, as second parameter a new instance of the object the PDOx should hydrate into, as third the parameters of your query and lastly the strategies. Strategies are a component of laminas hydrator and you can find our more about them here.
$pdo->fetchIterator($query, $prototype, $parameters, $strategies)
This method allows you to fetch an iterator of objects from the query and hydrate the results into a class of the type
of $prototype
. An example call can look like this:
The method call for fetchIterator
and fetchObject
is basically the same. You only need to replace the method name
and PDOx does the rest for you.
$pdo->fetchArray($query, $prototype, $parameters, $strategies)
This method allows you to fetch an iterator of objects from the query and hydrate the results into a class of the type
of $prototype
. An example call can look like this:
The method call for fetchArray
and fetchIterator
is basically the same. You only need to replace the method name and
PDOx does the rest for you.
Configuration
PDOx introduces two new fields for the PDO options. These are passed in the constructor. Using these new options you can
control whether PDOx should transform the field names and how it should handle empty results by returning null
or
throwing an exception.
PDOx::PDOX_NAMING_UNDERSCORE_TO_CAMELCASE
Possible Value: true
or false
Purpose: Controls whether the casing should be converted between underscore case in the database to CamelCase in PHP
PDOx::PDOX_NO_RESULT_BEHAVIOR
Possible value: PDOx::PDOX_NO_RESULT_BEHAVIOR_NULL
or PDOx::PDOX_NO_RESULT_BEHAVIOR_EXCEPTION
Purpose: Controls how PDOx should handle no result in fetchObject
Found a bug?
If you found a bug feel free to create an issue on Github or on our Taiga instance: https://taiga.imanuel.dev/project/pdox/
License
Like all other Jinya projects, PDOx is distributed under the MIT License.
All versions of pdox with dependencies
ext-pdo Version *
laminas/laminas-hydrator Version ^4.14.0
jetbrains/phpstorm-attributes Version ^1.0