PHP code example of faulkj / db

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

    

faulkj / db example snippets


use FaulkJ\DB;

$db = new DB("myhost", "mydb", "username", "password");

$respose = $db->query("SELECT * FROM mytable");
if(!$respose->success) echo(implode("\n", $respose->error));
else echo(json_encode($respose->result));


$params = [
   "apples",
   "oranges",
   12.34,
   5,
   true,
   null,
   321
];

if($dp->pQuery("
   UPDATE mytable
      SET favorite = ?
      , leastFavorite = ?
      , cost = ?,
      , count = ?
      , active = ?
      , nullable = ?
      WHERE id = ?
", $params)->success) {
   echo "Table updated";
 }