Download the PHP package ofmadsen/livid without Composer
On this page you can find all versions of the php package ofmadsen/livid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ofmadsen/livid
More information about ofmadsen/livid
Files in ofmadsen/livid
Package livid
Short Description Data Mapper (ORM) for PHP
License MIT
Homepage https://github.com/ofmadsen/livid
Informations about the package livid
Livid
Livid is a Data Mapper (ORM) for PHP.
Installation
Install the latest version with:
Features
- Uses
PDO
as database driver (supporting multiple database types) - Support connections to multiple databases (same and/or different types)
- Lazy-load connection to the database (connect when queried)
- Query result with single, all or scalar values
- Automatic conversion of column snake case naming to entity property camel case naming
Basic usage
Bootstrapping:
Mapper:
Note that Livid\Mapper
do not define a constructor method and mappers are therefore free to have anything injected. Injecting mappers into other classes are relatively cheap as the connection to the database are not established until needed and reused across mappers.
Fetch data in defined entities
Livid support entities with public, protected and private properties. The naming convention for entity properties in Livid is camel case and as such any column name that contains underscore are converted.
Example entity:
Example mapper:
As entities are simple container objects they can contain whatever methods and logic that suits the needs of the application.
Use multiple databases
Livid supports connections to multiple databases. Setting the database without a name will use the default name. Mappers that uses non-default databases must define the constant DATABASE
containing the name that the database was set with.
If multiple mappers uses the non-default database it might be easier to maintain if they extend a common class that defines the database name.
Supported databases
Only a subset of the PDO
supported databases are available for this library at the moment. If your preferred database is not present on the list below, feel free to contribute to the project.
MySQL
For MySQL database use Livid\Config\MySQLConfig
.
SQLite3
For SQLite3 database use Livid\Config\SQLite3Config
.
Interface
Available methods on Livid\Mapper
:
Available methods on Livid\Query
:
Contribution
All are welcome to contribute to Livid. Please get in touch before making large features and/or major refactoring. Needlessly to say the coding style must be followed and full test coverage is required.
License
Livid is available under the MIT License - see the LICENSE
file for details.