2017 © Pedro Peláez
 

library database

Connect to database server.

image

drago-ex/database

Connect to database server.

  • Friday, July 27, 2018
  • by accgit
  • Repository
  • 1 Watchers
  • 0 Stars
  • 213 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 23 % Grown

The README.md

Drago Database

Simple recurring questions., (*1)

License: MIT PHP version Tests Coding Style CodeFactor Coverage Status, (*2)

Technology

  • PHP 8.1 or higher
  • composer

Knowledge

Installation

composer require drago-ex/database

Use

#[Table('table', 'id')]
class Model {}

Basic queries in the Repository

Get records from table., (*3)

$this->model->table();

Search for a record by column name in the table., (*4)

$this->model->table('email = ?', 'email@email.com');

Search for a record by id., (*5)

$this->model->get(1);

Delete a record from the database., (*6)

$this->model->remove(1);

Save record (the update will be performed if a column with id is added)., (*7)

$this->model->put(['column' => 'record']);

Use of entity

class SampleEntity extends Drago\Database\Entity
{
    public const Table = 'table';
    public const PrimaryKey = 'id';

    public ?int $id = null;
    public string $sample;
}

Basic repository., (*8)

#[Table(SampleEntity::Table, SampleEntity::PrimarKey)]
class Repository {}

Use of an entity in a repository., (*9)

function find(int $id): array|SampleEntity|null
{
    return $this->get($id)->fetch();
}

Reading data., (*10)

$row = $this->find(1);
echo $row->id;
echo $row->sample;

Save records across an entity (to update the record we add id)., (*11)

$entity = new SampleEntity;
$entity->id = 1;
$entity->sample = 'sample';

$this->save($entity);

The save method saves the record to the database., (*12)

function save(SampleEntity $entity): Result|int|null
{
    return $this->put($entity);
}

Tips

You can also use entities and have them generated. https://github.com/drago-ex/generator, (*13)

The Versions

27/07 2018

dev-master

9999999-dev

Connect to database server.

  Sources   Download

MIT

The Requires

 

27/07 2018

v1.1.1

1.1.1.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

27/07 2018

v1.1.0

1.1.0.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

31/05 2018

v1.10

1.10.0.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

31/05 2018

v1.0.9

1.0.9.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

30/05 2018

v1.0.8

1.0.8.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

29/05 2018

v1.0.x-dev

1.0.9999999.9999999-dev

Connect to database server.

  Sources   Download

MIT

The Requires

 

29/05 2018

v2.0.x-dev

2.0.9999999.9999999-dev

Connect to database server.

  Sources   Download

MIT

The Requires

 

12/04 2018

v1.0.7

1.0.7.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

04/04 2018

v1.0.6

1.0.6.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

04/04 2018

v1.0.5

1.0.5.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

07/03 2018

v1.0.4

1.0.4.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

01/12 2017

v1.0.3

1.0.3.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

29/11 2017

v1.0.2

1.0.2.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

10/11 2017

v1.0.1

1.0.1.0

Connect to database server.

  Sources   Download

MIT

The Requires

 

18/10 2017

v1.0.0

1.0.0.0

Connect to database server.

  Sources   Download

MIT

The Requires