Download the PHP package phpixie/database without Composer
On this page you can find all versions of the php package phpixie/database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpixie/database
More information about phpixie/database
Files in phpixie/database
Package database
Short Description PHPixie Database library
License BSD-3-Clause
Homepage http://phpixie.com
Informations about the package database
PHPixie Database
Supports a common query interface for MySQL, PostgreSQL, SQLite and MongoDB
- PHPixie Database
- Initializing
- Querying
- Operators
- Tables, Subqueries and JOINs
- Aggregation
- Other types of queries
- Placeholders
- Transactions
- MongoDB
Initializing
If you are using the PHPixie Framework the Database component is automatically initalized for you. Access it via
$frameworkBuilder->components()->database()
and configure in the/config/database.php
file.
Querying
Querying relational database and MongoDB collections is very similar in PHPixie. Let's look at relational databases first
Using
and
,or
andxor
add conditions to the last used conditon type. So callingor
afterwhere()
will be same asorWhere()
, while using it afterhaving()
will be considered asorHaving()
.
Operators
Tables, Subqueries and JOINs
Aggregation
After you define you fields you cn use HAVING
in the same way you would use WHERE
;
Other types of queries
Placeholders
Query placeholders are another way to ease programmatic query building. You can create a placeholder and then later replace it with actual conditions. Here is an example:
Transactions
The basic usage for transactions is to rollback them if an exception occured and then rethrow the exception
PHPixie also supports transaction savepoints which can be used to for some more adavcenced behavior:
MongoDB
Querying MongoDB is very similar to querying SQL databases. Of course you can not use relational methods
like JOIN
and HAVING
statements, transactions, etc. But instead you get additional features in addition:
An easier way of querying subdocuments can be achieved using subdocument groups: