Download the PHP package habanero/grocery without Composer
On this page you can find all versions of the php package habanero/grocery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package grocery
The main purpose
Provide a simple (and fancy) interface to work with databases, currently supports PostgreSQL (8.4+), MySQLi (5.1+) and SQLite3 (3.7+) using the same API.
Perform migrations quickly, although you must write a wrapper for this if you want to keep the track.
First steps
You can just load tables and work with them almost easily, or you could create tables directly from the code and skip the CLI or GUI to achieve that.
There are generic types for creating new tables.
- primary_key: The most common field, conventionally named id
- integer: Basic numeric types, for relations, counting, etc.
- float: Extended numeric types for floating point values
- numeric: For money, decimals and other non-float values
- string: Varchar, char, etc. Default to 255 max-length
- text: For plain text without limits, depending on its driver
- binary: Blob values, but please do not save your files on the database
- boolean: Real booleans, chars or tiny-ints depending on its driver
- timestamp: Not *nix timestamp, alias for datetime indeed
- datetime: Common date+time strings like
date('Y-m-d H:i:s')
- date: Just the date part
Y-m-d
- time: The time part
H:i:s
About migrating
Grocery provides the hydrate()
helper method for this purpose.
Internally it will load the current details from the specified table, then compare and update your table definitions against your provided changes.
Notice that some operations are restrictive depending on the driver limitations.
Basic usage
Table access is granted through the $db[...]
syntax, most operations can be chained.
The last call MUST be a getter, e.g.
first()
,pick()
,get()
orall()
.
Installation
Using the composer is the best way to get installed Grocery as dependency.
Then include the vendor/autoload.php
script at the top of your project et voila.
Contribute!
So far there are many ways to work with Grocery but the README is too short already.
If you want to test and write some documentation, examples, etc. you're welcome to do pull-requests.