2017 © Pedro Peláez
 

library easydb

Short MySQL & PDO Proccess.

image

ibrahimozturkme/easydb

Short MySQL & PDO Proccess.

  • Wednesday, March 29, 2017
  • by ibrahimozturk.me
  • Repository
  • 1 Watchers
  • 2 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EasyDB, (*1)

Installing via Composer

`$ composer require "ibrahimozturkme/easydb":"dev-master", (*2)

Constructor

  • $database : String.
  • $host : String.
  • $username : String.
  • $password : String.
  • $charset : String.

Server Mode, (*3)

 $db = new \EasyDB\Connection('database_name', 'localhost', 'ibrahimozturk', '12341234', 'utf8');

Localhost mode, (*4)

 $db = new \EasyDB\Connection('database_name');

SQL

  • $proccess : String.
  • $table : String., (*5)

    $db->sql('select', 'articles');, (*6)


From

  • $fields : String., (*7)

    $db->sql('select', 'articles')->from('id, title, article');, (*8)


Serialize

  • $array : Array. Form data, (*9)

    $db->sql('insert', 'articles')->serialize($_POST)->result();, (*10)


Additional

  • $type : String.
  • $array : Array. Form data, (*11)

    $db->sql('update', 'articles')->serialize($array)->additional('WHERE id = :id', ['id' => 2])->result();, (*12)


Result

Query result., (*13)

 $db->sql('select', 'articles')->result();

Examples

SELECT - Single, (*14)

 $query    = $db->sql('select', 'articles')->additional('WHERE id = :id', ['id' => 2])->result();
 echo $query->count;
 echo $query->result->title;

SELECT - Multiple, (*15)

 $query    = $db->sql('select', 'articles')->result();
 echo $query->count;

 foreach($query->result as $row){
      echo $row->title.'<br>';
 }

SELECT - From, (*16)

 $query    = $db->sql('select', 'articles')->from('id, title, article')->result();
 echo $query->count;

 foreach($query->result as $row){
      echo $row->title.'<br>';
 }

INSERT, (*17)

 $insert   = $db->sql('insert', 'articles')->serialize($array)->result();
 echo $insert->last_id;
 echo ($insert->result) ? 'Has been added.' : 'Could not be added.';

UPDATE, (*18)

 $update   = $db->sql('update', 'articles')->serialize($array)->additional('WHERE id = :id', ['id' => 2])->result();
 echo ($update->result) ? 'Have been updated.' : 'Update failed.';

DELETE, (*19)

 $delete   = $db->sql('delete', 'articles')->additional('WHERE id = :id', ['id' => 2])->result();
 echo ($update->result) ? 'Has been deleted.' : 'Could not be deleted.';

The Versions

29/03 2017

dev-master

9999999-dev https://github.com/ibrahimozturkme/easydb

Short MySQL & PDO Proccess.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

php pdo mysql db