<?php require_once 'config.php'; use PDO\DB; // not recommened use // affectedRows = DB::i()->exec("DELETE FROM `users` WHERE id = ?", [2]); // recommended use, more $affectedRows = DB::i()->exec("DELETE FROM `users` WHERE id = :id", [':id' => 1]); dd($affectedRows);
<?php require_once 'config.php'; use PDO\DB; // not recommened use /** DB::i()->exec( "UPDATE `users` SET name = ?, email = ? WHERE id = ?", ["nick", "*****@*****.**", 98] ); **/ // recommended use, more readable $params = [":name" => "John Mayer", ":email" => "*****@*****.**", ":id" => 3]; $affectedRows = DB::i()->exec("UPDATE `users` SET name = :name, email = :email WHERE id = :id", $params); dd($affectedRows);
<?php require_once 'config.php'; use PDO\DB; // not recommended use /** DB::i()->exec( "INSERT INTO `users`(`name`, `address`, `email`) VALUES (?, ?, ?)", ['brian', 'labangon', '*****@*****.**'] ); **/ // recommended use, more readable DB::i()->exec("INSERT IGNORE INTO `users`(`name`, `address`, `email`) VALUES (:name, :address, :email)", [':address' => 'urgello', ':name' => 'Karl', ':email' => '*****@*****.**']); // dump data dd(DB::i()->getLastId());