Code Monkey home page Code Monkey logo

easydb's Introduction

EasyDB

Installing via Composer

`$ composer require "ibrahimozturkme/easydb":"dev-master"

Constructor

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

Server Mode

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

Localhost mode

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

SQL

  • $proccess : String.

  • $table : String.

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


From

  • $fields : String.

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


Serialize

  • $array : Array. Form data

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


Additional

  • $type : String.

  • $array : Array. Form data

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


Result

Query result.

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

Examples

SELECT - Single

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

SELECT - Multiple

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

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

SELECT - From

 $query    = $db->sql('select', 'articles')->from('id, title, article')->result();
 echo $query->count;
 
 foreach($query->result as $row){
      echo $row->title.'<br>';
 }

INSERT

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

UPDATE

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

DELETE

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

easydb's People

Contributors

ibrahimozturkme avatar irfanevrens avatar

Stargazers

 avatar Mahmut Yüksel Mert avatar  avatar

Watchers

 avatar

easydb's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.