Download the PHP package voku/simple-active-record without Composer
On this page you can find all versions of the php package voku/simple-active-record. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voku/simple-active-record
More information about voku/simple-active-record
Files in voku/simple-active-record
Package simple-active-record
Short Description Simple Active Record
License MIT
Homepage https://github.com/voku/simple-active-record
Informations about the package simple-active-record
:ring: Simple Active Record
This is a simple Active Record Pattern compatible with PHP 7+ that provides a simple and secure interaction with your database using :gem: "Simple MySQLi" at its core. This is perfect for small scale applications such as cron jobs, facebook canvas campaigns or micro frameworks or sites.
Get "Simple Active Record"
You can download it from here, or require it using composer.
Install via "composer require"
- Starting the driver
- Multiton && Singleton
- Doctrine/DBAL as parent driver
- Using the "ActiveRecord"-Class (OOP database-access)
- setDb(DB $db)
- insert() : bool|int
- fetch(integer $id = null) : bool|\ActiveRecord
- fetchAll() : $this[]
- update() : bool|int
- delete() : bool
- Active Record | SQL part functions
- select()
- from()
- join()
- where()
- group()
- order()
- limit()
- Active Record | WHERE conditions
- equal()/eq()
- notEqual()/ne()
- greaterThan()/gt()
- lessThan()/lt()
- greaterThanOrEqual()/ge()/gte()
- lessThanOrEqual()/le()/lte()
- like()
- in()
- notIn()
- isNull()
- isNotNull()/notNull()
- Active Record | Demo
- Logging and Errors
- Changelog
Starting the driver
Multiton && Singleton
You can use without any parameters and you will get your (as "singleton") first initialized connection. Or you can change the parameter and you will create an new "multiton"-instance which works like an singleton, but you need to use the same parameters again, otherwise (without the same parameter) you will get an new instance.
Doctrine/DBAL as parent driver
Using the "ActiveRecord"-Class (OOP database-access)
A simple implement of active record pattern via Arrayy.
setDb(DB $db)
set the DB connection.
insert() : bool|int
This function can build insert SQL queries and can insert the current record into database. If insert was successful, it will return the new id, otherwise it will return false or true (if there are no dirty data).
fetch(integer $id = null) : bool|\ActiveRecord
This function can fetch one record and assign in to current object. If you call this function with the $id parameter, it will fetch records by using the current primary-key-name.
fetchAll() : $this[]
This function can fetch all records in the database and will return an array of ActiveRecord objects.
update() : bool|int
This function can build update SQL queries and can update the current record in database, just write the dirty data into database. If update was successful, it will return the affected rows as int, otherwise it will return false or true (if there are no dirty data).
delete() : bool
This function can delete the current record in the database.
Active Record | SQL part functions
select()
This function can set the select columns.
from()
This function can set the table to fetch record from.
join()
This function can set the table to fetch record from.
where()
This function can set where conditions.
groupBy()
This function can set the "group by" conditions.
orderBy()
This function can set the "order by" conditions.
limit()
This function can set the "limit" conditions.
Active Record | WHERE conditions
equal()/eq()
notEqual()/ne()
greaterThan()/gt()
lessThan()/lt()
greaterThanOrEqual()/ge()/gte()
lessThanOrEqual()/le()/lte()
like()
in()
notIn()
isNull()
isNotNull()/notNull()
Active Record | Demo
Include && Init
Define Class
Init data (for testing - use migrations for this step, please)
Insert one User into database.
Insert one Contact belongs the current user.
Example to using relations
Changelog
See CHANGELOG.md.
Support
For support and donations please visit Github | Issues | PayPal | Patreon.
For status updates and release announcements please visit Releases | Twitter | Patreon.
For professional support please contact me.
Thanks
- Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
- Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
- Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
- Thanks to StyleCI for the simple but powerfull code style check.
- Thanks to PHPStan && Psalm for relly great Static analysis tools and for discover bugs in the code!
All versions of simple-active-record with dependencies
voku/arrayy Version ~7.0
voku/simple-mysqli Version ~8.0
hashids/hashids Version ~2.0 || ~3.0 || ~4.0