updated readme
This commit is contained in:
parent
b6c9da5890
commit
7f70b8839e
1 changed files with 7 additions and 28 deletions
35
README.md
35
README.md
|
@ -20,23 +20,16 @@ In order to read/write objects from a database table, you'll need to configure a
|
|||
```php
|
||||
// DriverFactory::factory() has the same arguments as PDO::__construct
|
||||
// You can also construct a driver directly, from a class in Drivers,
|
||||
// but for common databases DriverFactory::factory should pick the right class.
|
||||
// Note: It's important to specify a character set, because malformed characters
|
||||
// completely break PHP's json_decode() function.
|
||||
// but for common databases DriverFactory::factory should pick the right class
|
||||
$driver = \Destructr\DriverFactory::factory(
|
||||
'mysql:host=127.0.0.1;charset=utf8',
|
||||
'mysql:host=127.0.0.1',
|
||||
'username',
|
||||
'password'
|
||||
);
|
||||
// Driver is then used to construct a Factory
|
||||
$factory = new \Destructr\Factory(
|
||||
// a Driver is used to manage connection and generate queries
|
||||
$driver,
|
||||
// all of a Factory's data is stored in a single table, to split data between
|
||||
// multiple tables, you'll need to create multiple Factories. Drivers can be
|
||||
// reused across multiple Factories, and only a single connection will be
|
||||
// used, if supported by the database.
|
||||
'dso_objects'
|
||||
$driver, //driver is used to manage connection and generate queries
|
||||
'dso_objects' //all of a Factory's data is stored in a single table
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -46,13 +39,8 @@ Next, you can use the factory to create a new record object.
|
|||
|
||||
```php
|
||||
// by default all objects are the DSO class, but factories can be made to use
|
||||
// other classes depending on what data objects are instantiated with.
|
||||
// create() can be optionally given an array of initial data.
|
||||
$obj = $factory->create(['foo'=>'bar');
|
||||
|
||||
// once created, an object can be worked with like a SelfReferencingFlatArray
|
||||
// see https://gitlab.com/byjoby/flatrr for more information about that
|
||||
$obj['bar.baz'] = 'buzz';
|
||||
// other classes depending on what data objects are instantiated with
|
||||
$obj = $factory->create();
|
||||
|
||||
// returns boolean indicating whether insertion succeeded
|
||||
// insert() must be called before update() will work
|
||||
|
@ -78,20 +66,11 @@ $obj->delete(true);
|
|||
|
||||
## Requirements
|
||||
|
||||
### Suggested databases
|
||||
|
||||
Currently, Destructr is best supported by MySQL 5.7, SQLite 3, and MariaDB >=10.2.
|
||||
|
||||
The SQLite driver is actually very fast in benchmarks, and performs very close to the same speed as MySQL 5.7 for simple queries or small databases with object counts on the order of a few thousand.
|
||||
For efficient indexing of non-standard JSON paths or large numbers of objects, MySQL 5.7 or MariaDB >=10.2 is highly recommended.
|
||||
|
||||
### Theoretical minimum versions
|
||||
|
||||
This system relies **heavily** on the JSON features of the underlying database.
|
||||
This means it cannot possibly run without a database that supports JSON features.
|
||||
Exact requirements are in flux during development, but basically if a database doesn't have JSON functions it's probably impossible for Destructr to ever work with it.
|
||||
|
||||
In practice this means Destructr will **never** be able to run properly on less than the following versions of the following popular databases:
|
||||
In practice this means Destructr will **never** be able to run on less than the following versions of the following popular databases:
|
||||
|
||||
* MySQL >=5.7
|
||||
* MariaDB >=10.2
|
||||
|
|
Loading…
Reference in a new issue