aidsoul/pdo

v1.2 2023-08-21 11:45 UTC

This package is auto-updated.

Last update: 2024-04-21 13:31:07 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f616964736f756c2f70646f

PDO query builder

Installation

Installation with the command:

composer require aidsoul/pdo

Example Usage

require_once  __DIR__  .  '/vendor/autoload.php';
use Aidsoul\Pdo\Db;

$host  =  'localhost';
$dbName  =  'test';
$user  =  'root';
$pass  =  '';

$db  =  new  Db("mysql:host={$host};dbname={$dbName}",  $user,  $pass);

// SELECT
$db->select()
->from('post')
->join('vkgroup')->on('group_id','id_group')
->orderBy(['id_post'  =>'ASC'])
->limit(50)
->execute()
->fetchAll();

// INSERT
$db->insert(['id_post','group_id'])
->into('post')
->values([66,28])
->execute();

// DELETE
$db->delete()
->from('post')
->where('group_id','=',113)->and('id_post','=',147)
->execute();

// UPDATE
$db->update('vkgroup')
->set(['name'=>'test'])
->where('id_group','=',111)
->and('name','=','before the test')
->execute();