PHP code example of fatrbaby / knob
1. Go to this page and download the library: Download fatrbaby/knob 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/ */
fatrbaby / knob example snippets
use Knob\Knob;
// Set PDO connection (driver is auto-detected)
Knob::using($pdo);
// Build queries
$users = Knob::table('users')
->select('id', 'name', 'email')
->where('status', 'active')
->orderBy('created_at', 'DESC')
->limit(10)
->get();
// Insert
Knob::table('users')->insert([
['name' => 'Alice', 'email' => '[email protected]'],
]);
// Update
Knob::table('users')
->where('id', 1)
->update(['name' => 'Updated Name']);
// Delete
Knob::table('users')->where('id', 1)->delete();
// Aggregates
$count = Knob::table('users')->count();