PHP code example of mugomes / miphantdblite

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

    

mugomes / miphantdblite example snippets


use MiPhantDBLite\database;

$db = new database(
    'database.sqlite',
    true // modo sandbox (erros exibidos na tela)
);

$db = new database(
    'database.sqlite',
    false,
    database::READWRITE | database::CREATEONLY
);

use MiPhantDBLite\select;

$select = new select('database.sqlite');

$select->table('users')
    ->column('id')
    ->column('name')
    ->where('status', 'ativo')
    ->order('name')
    ->limit(0, 10)
    ->select();

while ($row = $select->fetch()) {
    echo $row['name'];
}

$select->close();

$select->activatePrepared()
    ->table('users')
    ->where('id', 1)
    ->select();

$row = $select->fetch();
$select->close();

use MiPhantDBLite\insert;

$insert = new insert('database.sqlite');

$insert->activatePrepared()
    ->table('users')
    ->insertValue('name', 'João')
    ->insertValue('email', '[email protected]')
    ->insert();

$id = $insert->idInsert();
$insert->close();

use MiPhantDBLite\update;

$update = new update('database.sqlite');

$update->activatePrepared()
    ->table('users')
    ->updateValue('email', '[email protected]')
    ->where('id', 1)
    ->update();

$update->close();

use MiPhantDBLite\delete;

$delete = new delete('database.sqlite');

$delete->table('users')
    ->where('id', 1)
    ->delete();

$delete->close();

use MiPhantDBLite\table;

$table = new table('database.sqlite');

$table->table('users')
    ->setInt()->primaryKey()->autoIncrement()->insertColumn('id')
    ->insertColumn('name')
    ->insertColumn('email')
    ->create();

$table->close();

$db->close();