PHP code example of alexccavaco / database

1. Go to this page and download the library: Download alexccavaco/database 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/ */

    

alexccavaco / database example snippets


  $r=DBSelect::from('table')
    ->select('*')
    ->where('column1 = ?', $data1)
    ->where('column2 = ?', $data2)
    ->orderBy('name')
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

  $r=DBUpdate::table('table')
    ->set('column','?',$param)
    ->setAll(['column'=>$param,'anotherCol'=>$param2])
    ->where('column = ?','data')
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

  $r=DBInsert::into('table')
    ->value('column1',$param1)
    ->value('column2',$param2,true) //The third parameter if true automatically sets On Duplicate Update
    ->values(['column'=>$param])
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);