2017 © Pedro Peláez
 

library milchkuh

A wrapper class (trait) of PDO.

image

chloe463/milchkuh

A wrapper class (trait) of PDO.

  • Tuesday, February 28, 2017
  • by chloe463
  • Repository
  • 1 Watchers
  • 0 Stars
  • 67 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 19 Versions
  • 8 % Grown

The README.md

Milchkuh

Build Status, (*1)

Summary

This is a wrapper class (trait) of PDO., (*2)

You can access MySQL database with simple APIs., (*3)

Install

$ composer require chloe463/milchkuh

Usage

<?php

use chloe463\Milchkuh\Milchkuh;
use chloe463\Milchkuh\Exception;

class AwesomeClass
{
    use Milchkuh;

    public function __construct()
    {
        $db_info = [
            // These are essential keys
            'host'       => 'localhost',
            'port'       => 3306,
            'user'       => '',
            'pass'       => '',
            'db_name'    => 'db',

            // table_name is optional
            'table_name' => 'table'
        ];
        $this->init($db_info);
    }

    public function doSomething()
    {
        // SELECT
        $records = [];
        try {
            $records = $this->select($query, $bind_param);
        } catch (Exception $e) {
            // Handle exception
        }

        // INSERT
        $last_insert_id = null;
        try {
            $last_insert_id = $this->insert($query, $bind_param);
        } catch (Exception $e) {
            // Handle exception
        }

        // UPDATE
        $row_count = null;
        try {
            $row_count = $this->update($query, $bind_param);
        } catch (Exception $e) {
            // Handle exception
        }

        // DELETE
        $row_count = null;
        try {
            $row_count = $this->delete($query, $bind_param);
        } catch (Exception $e) {
            // Handle exception
        }

        // SLEEP
        $this->nap(3);

        // There are some transaction APIs
        try {
            $this->begin();

            // Execute query

            $this->commit();
        } catch (Exception $e) {
            $this->rollBack();
        }
    }
}

Other features

  • QueryBuilder helps you to build SQL
$qb = new QueryBuilder();
$qb->append('SELECT * FROM db.table')
   ->append(' WHERE column1 = :column1')
   ->append(' AND column2 = :column2', isset($values['column2']));

$query = $qb->getQuery();
// If $values['column2'] is set
// SELECT * FROM db.table WHERE column1 = :column1 AND column2 = :column2
//
// If $values['column2'] is NOT set
// SELECT * FROM db.table WHERE column1 = :column1
  • Logger logs queries
    • To enable logger, just pass path to log file as 2nd argument to chloe463\Milchkuh\Milchkuh::init php // Query logs are going to /path/to/log_file $this->init($connection_info, '/path/to/log_file');

The Versions

28/02 2017

dev-tests/replace-functions

dev-tests/replace-functions

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

08/02 2017

dev-master

9999999-dev

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

06/02 2017

v1.2.2

1.2.2.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

05/02 2017

dev-feature/charset

dev-feature/charset

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

05/02 2017

v1.2.1

1.2.1.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

17/01 2017

dev-refactor/logger

dev-refactor/logger

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

03/01 2017

v1.2.0

1.2.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

03/01 2017

dev-feature/build-bind-param

dev-feature/build-bind-param

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

01/01 2017

v1.1.1

1.1.1.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

31/12 2016

v1.1.0

1.1.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

31/12 2016

dev-feature/logger

dev-feature/logger

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

30/12 2016

v1.0.1

1.0.1.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

30/12 2016

v1.0.0

1.0.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

30/12 2016

v0.3.1

0.3.1.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

30/12 2016

v0.3.0

0.3.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by TsuyoshiHara

30/12 2016

v0.2.0

0.2.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by TsuyoshiHara

30/12 2016

v0.1.2

0.1.2.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by TsuyoshiHara

30/12 2016

v0.1.1

0.1.1.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by TsuyoshiHara

26/12 2016

v0.1.0

0.1.0.0

A wrapper class (trait) of PDO.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by TsuyoshiHara