PHP code example of aidsoul / pdo

1. Go to this page and download the library: Download aidsoul/pdo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aidsoul / pdo example snippets



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();