Download the PHP package docnet/php-dbal without Composer
On this page you can find all versions of the php package docnet/php-dbal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download docnet/php-dbal
More information about docnet/php-dbal
Files in docnet/php-dbal
Package php-dbal
Short Description A library which wraps mysqli into a fluent, easy-to-use set of classes.
License Apache-2.0
Homepage https://github.com/DocnetUK/php-dbal
Informations about the package php-dbal
PHP DB Access Layer
Designed to wrap mysqli into a series of fast, secure and easy to use classes.
Install with Composer
Require line as follows
"docnet/php-dbal": "v2.1"
Let's Connect
You're gonna need to connect to a DB before you can do anything else...
For the following examples, we'll assume there's an active DB object.
My First SELECT
After this has executed, $records
will be an array of stdClass
objects - see how to change the result class later.
SELECT One Record
After this has executed, $record
will be a stdClass object.
Result Class
If we pass in an optional third parameter, we'll get back an object of that class
So now, $foo
is an instance of class Foo
SELECT with parameters and result Class
After execution, $records
is an array of (namespaced) \Docnet\Bar
objects, where intKey > 3 and vchName = Barry
The prepare()
method returns a fluent Statement
class which provides named parameter binding.
Parameter binding deals with all escaping and quoting for you.
INSERT, UPDATE, DELETE
Insert, update and delete operations (also called DML queries) work in just the
same way as the fetch
methods.
Return Values
insert()
returns the last insert idupdate()
anddelete()
return the number of affected rows
Re-executing Prepared Statements
For SELECTs
Or, more commonly, INSERTs - this can be MUCH higher performance than running multiple INSERT queries as the server only interprets the SQL string once.
Arbitrary SQL
If you REALLY need to, you can just run arbitrary queries like this:
Binding
Binding is great. It allows the DBAL to take care of escaping AND quoting.
There are quite a few different supported binding methods (probably too many, but I'm keen to be flexible).
Shorthand, single scalar value
Shorthand array of parameters - parameter sequence must match your query
Shorthand array of named parameters - any sequence, types auto-detected
Long-hand typed, named binding - fluent, any sequence
Long-hand type-hinted, named binding - fluent, any sequence
Public Methods
DB Class
The following methods are available
fetchOne()
fetchAll()
insert()
update()
delete()
prepare()
which returns a newStatement
object when calledquery()
escape()
begin()
Transaction supportcommit()
Transaction supportrollback()
Transaction support
Statement Class
SELECT
fetchOne()
fetchAll()
setResultClass()
DML
insert()
update()
delete()
Binding
bind()
bindInt()
bindString()
bindDouble()
bindBlob()
Post execution
getInsertId()
getAffectedRows()
All versions of php-dbal with dependencies
ext-mysqli Version *