PHP code example of zilus / pdo

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

    

zilus / pdo example snippets


$database = new Database(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sql="SELECT * FROM table WHERE lastname = :lastname";
$database->query($sql);
$database->bind(':lastname', 'Smith');
$rows = $database->resultset();
foreach($rows as &$row) {
  echo $row['lastname'];
}

$id = 14;
$database = new Database(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sql="DELETE FROM table WHERE id = :id";
$database->query($sql);
$database->bind(':id', $id);
$database->execute();

$database = new Database(DB_HOST, DB_USER, DB_PASS, DB_NAME);
print_r($database->error);