1. Go to this page and download the library: Download patryknamyslak/patbase 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/ */
patryknamyslak / patbase example snippets
use PatrykNamyslak\Patbase\Facades\DB;
use PatrykNamyslak\Patbase\Enums\WhereOperator;
// SELECT * FROM `blog` WHERE views < :views;
$selectQuery = DB::select([*])->from("blog")->where("views", WhereOperator::LESS_THAN, 500)->all()
// The all() method runs the query by automatically swapping in the parameters in for the value you set in the where part of the chain!
DB::insert()->into("table")->set("title", "New Post title");
DB::upsert(["title"])->into("table")->...;
// OR
DB::insertOrUpdate()
DB::delete()->from("blog")->where("title", WhereOperator::LIKE, "Flag API");
DB::update()->table("table")->...;
use PatrykNamyslak\Patbase\Patbase;
use PatrykNamyslak\Patbase\Enums\DatabaseDriver;
$db = new Patbase(
driver: DatabaseDriver::MYSQL,
database: 'myapp',
username: 'root',
password: 'Password123@',
host: 'localhost',
port: NULL, // NULL (or omit as the default is NULL) or your custom port, NULL will default to the port based on driver type i.e MYSQL = 3306
);
$users = $db->query("SELECT * FROM `users`;")->fetchAll();