Download the PHP package naga3/qb without Composer
On this page you can find all versions of the php package naga3/qb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package qb
Short Description Qb: Simple query builder
License MIT
Informations about the package qb
Qb: Simple query builder
This was assumed per the provision of the back-end API, a simple PDO query builder. I was created in mind is that the write as short as possible the code.
Just only this you can return a list of the contact table in JSON.
Audiences
Though it is to use the raw PDO as it is troublesome, who full-fledged DB library feels overkill function.
Resources
doc/index.html is a reference.
- GitHub https://github.com/naga3/qb
- Packagist https://packagist.org/packages/naga3/qb
How to install
only require 'qb.php'.
If you use the Composer is,
Install Now you read in the autoload.
Samples
sample/contact.php is a sample of a simple contact list. sample/todo.php is a sample of the ToDo list that combines AngularJS. Both samples PDO_SQLITE module is I will work as it is if it is introduced.
API
Connection
Connect to the specified DSN.
SELECT
It will return a list of the contact table in JSON.
It will return the name column and tel column of the table contact list in the array.
name column of the table contact list I returned unchanged. And tel column will return as an object with an alias t.
WHERE
id column of contact table will return one line of 1.
There is also such shorthand.
In status column of the contact table is 1 or more, it will return the ones that contain "Yamada" in the name.
JOIN
INNER JOIN. 'access.contact_id = contact.id' is binding conditions.
LEFT OUTER JOIN.
INSERT
to contact table name column is "Ichiro Suzuki", insert the record age column is "19". The return value is the value of the primary key.
INSERT or UPDATE
In an attempt to first UPDATE If there is a WHERE clause to INSERT if there is no record of the target.
UPDATE
Here even if there is no record of the target will not be INSERT.
1 column only change you can also be written as this.
SET
INSERT and from connecting the chain set, you can UPDATE.
DELETE
age column of contact table will remove all 20 of the record.
id column of contact table will delete a record.
ORDER BY
It will return a list of the contact table in ascending order of created_at column.
It will return a list of the contact table in descending order of created_at column, in ascending order of id.
OFFSET, LIMIT
You get 5 from 10 th in the list of contact table.
PDO object acquisition
You get the raw PDO object. Please, for example, when you put the transaction.
Option when connecting
important point
- 1 Program 1 connection with the assumption, is not suitable for large-scale programs.