Download the PHP package hwalde/pooq without Composer
On this page you can find all versions of the php package hwalde/pooq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pooq
POOQ - PHP Object Oriented Querying
POOQ generates PHP code from your database and lets you build type safe SQL queries through its fluent API.
WARNING: POOQ is currently in alpha stage! Expect API changes. Expect bugs! Do not use it in production!
Benefits
- It creates PHP code from your database.
- It can map the result of queries to objects.
- It allows you to write type-safe sql-queries.
- You won't run into typical ORM problems when it comes to more complicated queries (unexpected behavior or performance problems which need deep insight knowledge into your ORM software to solve)
Requirements
- PDO with MySQL (and should work with MariaDB as well)
Installation
I recommend to use Composer for installation:
Then use Composers autoload functionality to include POOQ into your projects:
Example usage
Querying
Initialize for querying
Before querying you need to initialize POOQ once.
Alternatively an existing PDO can be used:
Creating a select query
Outputs:
Alias names are optional. You can always use the models directly:
Outputs:
Mapping results to objects (so called Records)
Records can be optionally inserted/updated/refreshed/deleted in an ORM fashion
Converting Records to arrays
POOQ can handle queries with overlapping column names (from different tables). For example, if forum and thread would both have a column "title" then each value would still be mapped to the correct object.
Execute update queries
executes query:
Using subqueries in update:
executes query:
Custom WHERE-clauses
Not everything is implemented yet.. so being able to write custom where clauses is quite useful:
Code Generation
Contribution
Feel free to improve POOQ and send me your Pull Requests.
Don't worry about code style or anything else. I can still adapt your changes if necessary.
I'm happy about every contribution.
Feel free to ask me anything!
Have a nice day!