Download the PHP package safronik/db-wrapper without Composer
On this page you can find all versions of the php package safronik/db-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download safronik/db-wrapper
More information about safronik/db-wrapper
Files in safronik/db-wrapper
Package db-wrapper
Short Description Wrapper for different relation databases drivers such as PDO, Mysqli, WPDB, Drupal, and any other
License MIT
Homepage https://github.com/Safronik/project-db-wrapper
Informations about the package db-wrapper
safronik/db-warapper
A PHP library contains database wrapper to simplify it's usage
About
This package contains wrapper for database, includes drivers for different databases:
- PDO
mysqli(in development)- Wordpress
Joomla(in development)Drupal(in development)- ...
There is a namespace "Extensions" contains extensions for this DB wrapper. And few extensions to ease the programmer life:
- Query builder
- Operations with tables
- Placeholders for input data (works natively, you want see it)
- Server side prepared extensions (works only for PDO)
SQL Schema(in development)
Installation
The preferred method of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
or just download files or clone repository (in this case you should bother about autoloader)
Usage
Creating a connection
If you are using PDO (you don't have any ready connection)
Existing PDO connection:
Because it's driver is PDO by default this should work too:
For WordPress:
Raw query
Query builder
Builder using a fluid (waterfall) interface
Select
Methods allowed:
- table
- columns
- join (look for Join description below)
groupBy(in development)having(in development)- orderBy
- limit
- with (look for CTE description below)
- run
Insert
Methods allowed:
- columns
- ignore
- values
- onDuplicateKey
- run
Update
Methods allowed:
- set
- where
- and
- or
- run
Delete
Methods allowed:
- where
- and
- or
- orderBy
- limit
- run
Join (only as part of Select statement)
- Supports left, right and inner joins passed as the second argument
- Join operator supports <=> | != | > | < | >= | <= but it's not certain =D
- All columns from the joined table will be selected if no specified
CTE (Common Table Expression)
When you call with() you should pass the $db->cte() inside
So the all 3 methods ( cte()
, anchor()
and recursive()
) should be called
cte()
set the name of your common table expression. You can think that it's a table name.
anchor()
is the root select expression
recursive()
recursive expression
Any select expression could be any level of difficulty, using joins, orders and other
You can also use a query builder in these anchor
and recursive
expressions
Tables operations
Exists
Checks if the table exists
Drop
Drops a table
Create
Some day I will add the documentation
Alter
Some day I will add the documentation