PHP code example of celiovmjr / simplequery

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

    

celiovmjr / simplequery example snippets


use Builder\Application\SimpleQuery;

// Assuming $connection is your PDO connection
class User extends SimpleQuery
{
    protected string $table = 'users'; // Ignore if your table name is the same as the class (plural form)
    protected string $primaryKey = 'id'; // Ignore if your primary key is 'id'
    protected array $

$user->fromArray(['name' => 'John Doe', 'age' => 30]);

$results = $user->select()->where('age > :age', ['age' => 25])->fetch(true);

// Create
$user->fromArray([
    'name' => 'Jane Doe',
    'age' => 28
]);
$user->save();

// Read
$user->select()->where('id = :id', ['id' => 1])->fetch();

// Update
$user->name = 'New Name';
$user->save();

// Delete
$user->delete(1);