<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
karlpatrickespiritu / simple-php-pdo-wrapper example snippets
use PDO\DB;
$singleRow = DB::i()->fetch('SELECT * FROM `users` WHERE `name` = :name', ['name' => 'Justin Beiber']);
$multipleRows = DB::i()->fetchRows('SELECT * FROM `users`');
$multipleRows = DB::i()->fetchRows('SELECT * FROM `users`');
$rows = DB::i()->getRowCount(); // get the number of rows returned
$columns = DB::i()->getColumnCount(); // get the number of columns per row
var_dump($multipleRows);
var_dump($rows);
var_dump($columns);
$params = [
':address' => 'Urgello St., Cebu City, 6000, Cebu',
':name' => 'Karl Espiritu',
':email' => '[email protected]'
];
DB::i()->exec("INSERT INTO `users`(`name`, `address`, `email`) VALUES (:name, :address, :email)", $params);
var_dump(DB::i()->getLastId()); // dumps the last inserted id
$params = [
":name" => "John Mayer",
":email" => "[email protected]",
":id" => 3
];
$affectedRows = DB::i()->exec("UPDATE `users` SET name = :name, email = :email WHERE id = :id", $params);
var_dump($affectedRows); // dumps the number of affected rows
$affectedRows = DB::i()->exec("DELETE FROM `users` WHERE id = :id", [':id' => 1]);
var_dump($affectedRows); // dumps the number of affected rows