PHP code example of artemmelnik / devstart-db

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

    

artemmelnik / devstart-db example snippets


  
  
  Start\Database;
  
  $db = new Database([
     'host' => 'localhost',
     'dbname' => 'devstart_db',
     'user' => 'root',
     'password' => 'root',
     'charset' => 'utf8'
  ]);
  
  $query = $db->query('SELECT * FROM posts ORDER BY id DESC');
  
  $db->closeConnection();
  

    
    
    $insert = $db->query("INSERT INTO posts (title, content) VALUES (:title, :content)", [
        'title' => 'Hello World',
        'content' => 'Wrire content'
    ]);