Download the PHP package minphp/record without Composer
On this page you can find all versions of the php package minphp/record. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download minphp/record
More information about minphp/record
Files in minphp/record
Package record
Short Description Database Access Library
License MIT
Homepage http://github.com/phillipsdata/minphp-record
Informations about the package record
Minphp/Record
Database Access Library.
Provides a fluent interface for generating and executing SQL queries.
Installation
Install via composer:
Usage
First, initialize your connection:
Select
Select statements must end with one of the following:
fetch()
fetch a single recordfetchAll()
fetch all recordsgetStatement()
fetch the\PDOStatement
object which you can iterate overget()
fetch the SQL query
All
Tuples
Tuple Aliasing
Value Injection
Aggregate Functions
Number of Results
Number of Rows Affected
Last Insert ID
Limiting
Limit 10 records:
Limit 10 records, starting at record 20:
Ordering
Grouping
Where
Operators include:
=
equality!=
,<>
inequality>
greather than>=
greather than or equal<
less than<=
less than or equalin
in the given valuesnotin
not in the given valuesexists
exists in the result setnotexists
does not exist in the result set
Note: If null
is supplied as the value, with =
or !=
the result becomes IS NULL
or IS NOT NULL
, respectively.
Simple Where
And Where
Or Where
Where In
Simple Like
And Like
Or Like
Simple Having
And Having
Or Having
Conditional Grouping
Joins
Each join method supports a single conditional. To add additional conditionals, simply precede the join with an on()
call. For example on('column1', '=', 'column2', false)
.
Inner Join
The 5th parameter to tells the join that users.user_group_id
is a field, not a value. Consider the following, instead:
Left Join
Right Join
Cross Join
Subqueries
Tip: Avoid these at all costs. Subqueries are incredibly inefficient. This isn't a limitation of this library, rather of the underlying relational database system.
All subqueries start first with the subquery. The idea is to construct the query from the inside out, and as each layer is added the subquery becomes part of the parent query.
Insert
Simple Insert
Insert with Filter
On Duplicate
From a Query
Update
Simple Update
Update with Filter
Delete
Simple Delete
Multi-delete
Create Table
Alter Table
The 3rd parameter to setKey
is the name of the index. The 4th parameter identifies whether this is an add or a drop.