PHP code example of avryhof / database

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

    

avryhof / database example snippets


   
  $db = new Database("mysql://user:pass@localhost/database");
  
  or
  
  $db = new Database("sqlite:///home/user/data/users.db?mode=0666");
  
  /* The Code Below works the same on all supported databases! */
  
  $db->insert("users", array("name" => "User", "password" => "{password}", "email" => "[email protected]"));
  
  $users = $db->query("SELECT * FROM users WHERE name = 'User'");

  if ($users->num_rows > 0) {
    while($user = $users->fetch_assoc()) {
      echo "<pre>" . print_r($user,true) . "</pre>";
    }
  }
  
  $db->update("users", array("name" => "Bob"),"name = 'User'");
  
  $db->delete("users", "name = 'Bob'");