PHP code example of nkt / flame

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

    

nkt / flame example snippets




use Flame\Connection;
use Flame\Grammar\MysqlGrammar;

$db = new Connection('mysql:dbname=hello_world', 'user', 'password', [], new MysqlGrammar());
$db->prepare(...);

$users = $flame->prepare(
    'SELECT * FROM users WHERE age >= i:age OR (registered < d:registered AND age = :age)'
)->execute(['age' => $age]);

$stmt = $flame->prepare('SELECT * FROM users WHERE id = i:id)');
$users = $stmt->execute(['id' => $_POST['id']]);

$stmt = $flame->prepare('INSERT INTO users VALUES(s:username, d:last_login))');
$users = $stmt->execute(['username' => 'John Doe', 'last_login' => null]);

$posts = $db->prepare(
    $db->select('p.id', 'p.title', 'p.content')
       ->from('posts p')
       ->join('post_tags pt', 'p.id', 'pt.post_id')
       ->join('tags t', 't.id', 'pt.tag_id')
       ->where(function ($e) {
           $e->equal('t.name', ':tag');
       })
)->execute(['tag' => $tag]);

$db->prepare($db->insert('users', [
        'username'   => ':name',
        'password'   => ':pass',
        'registered' => 'd:now'
    ]))->execute([
        'name' => $name,
        'pass' => $pass,
        'now'  => new \DateTime()
   ]);