2017 © Pedro Peláez
 

library landa-db

Mysql POD library

image

cahkampung/landa-db

Mysql POD library

  • Tuesday, January 9, 2018
  • by agung052
  • Repository
  • 1 Watchers
  • 0 Stars
  • 334 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 11 % Grown

The README.md

Landa DB

Simple Mysql PDO CRUD library, (*1)

Installation

Install with Composer, (*2)

Add cahkampung/landa-db to require in composer.json, (*3)

"require": { "cahkampung/landa-db": "^1.2" },, (*4)

Run composer install, (*5)

How To Use

Connection

$config = [
  'DB_DRIVER'      => 'mysql',
  'DB_HOST'        => 'localhost',
  'DB_USER'        => 'root',
  'DB_PASS'        => 'password',
  'DB_NAME'        => 'database',
  'CREATED_USER'   => 'created_by',
  'CREATED_TIME'   => 'created_at',
  'CREATED_TYPE'   => 'int',
  'MODIFIED_USER'  => 'modified_by',
  'MODIFIED_TIME'  => 'modified_at',
  'MODIFIED_TYPE'  => 'int',
  'DISPLAY_ERRORS' => false,
  'USER_ID'        => $_SESSION['user']['id'],
];

$db = new Cahkampung\Landadb($config);

Insert

$db->insert(TABLE_NAME, DATA);, (*6)

Example :, (*7)

$data = [
  'name' => 'john',
  'email' => 'john@example.com'
];

$db->insert('user_table', $data);

Update

$db->update(TABLE_NAME, DATA, PARAMS);, (*8)

Example :, (*9)

$data = [
  'name' => 'john',
  'email' => 'john@example.com'
];

$db->update('user_table', $data, ['id' => 1]);

Delete

$db->delete(TABLE_NAME, PARAMS);, (*10)

Example :, (*11)

$db->delete('user_table', ['id' => 1]);

Select

select()

select(FIELDS), (*12)

FIELDS can be array format, default value is *, (*13)

from()

from(TABLE), (*14)

where()

where(FIELD_NAME, FILTER, VALUE), (*15)

andWhere()

andWhere(FIELD_NAME, FILTER, VALUE), (*16)

orWhere()

andWhere(FIELD_NAME, FILTER, VALUE), (*17)

customWhere()

customWhere(WHERE_STRING, FILTER), (*18)

Default filter is And, (*19)

Example :, (*20)

customWhere('name = "john" or nationallity = "indonesia"', 'AND');, (*21)

Will generate AND (name="john" or nationallity="indonesia");, (*22)

join()

join(JOIN TYPE, TABLE, ONCLAUSE), (*23)

leftJoin()

leftJoin(TABLE, ONCLAUSE), (*24)

rightJoin()

rightJoin(TABLE, ONCLAUSE), (*25)

innerJoin()

innerJoin(TABLE, ONCLAUSE), (*26)

limit()

limit(INT), (*27)

offset()

offset(INT), (*28)

orderBy()

orderBy(FIELD), (*29)

groupBy

groupBy(FIELD), (*30)

findAll()

Fetch all result from query, (*31)

Example :, (*32)

$db->findAll('select * from user_table where name like "%john%" order by name ASC limit 10 offset 0');

Or, (*33)

$db->select()
    ->from('user_table')
    ->where('name','LIKE','john')
    ->limit(10)
    ->offset(0)
    ->orderBy('name ASC')
$getUsers = $db->findAll();

find()

Fetch 1 results from query, (*34)

Example :, (*35)

$db->find('select * from user_table where name like "%john%" order by name ASC');

Or, (*36)

$db = new Cahkampung\Landadb;
$db->select()
    ->from('user_table')
    ->where('name','LIKE','john')
    ->orderBy('name ASC')
$getUsers = $db->find();

The Versions

09/01 2018

dev-master

9999999-dev

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

09/01 2018

1.2.3

1.2.3.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

09/09 2017

1.2.2

1.2.2.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

19/06 2017

1.2.1

1.2.1.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

13/04 2017

1.2

1.2.0.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

31/03 2017

1.1

1.1.0.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim

24/03 2017

1.0

1.0.0.0

Mysql POD library

  Sources   Download

dbad

The Requires

  • php >=5.4
  • ext-pdo *

 

by Wahyu Agung Tribawono

database framework pdo slim