PHP code example of esoastor / database-manager
1. Go to this page and download the library: Download esoastor/database-manager 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/ */
esoastor / database-manager example snippets
use SqliteOrm\Schema\Sqlite\SqliteConstructor;
$constructor = new SqliteConstructor();
$blueprint = $constructor->getBlueprintBuilder();
$constructor->createTable('test', [
$blueprint->id(),
$blueprint->text('login')->length(50)->notNull(),
$blueprint->integer('number')->notNull(),
]);
$test = $constructor->getDatabase('test');
$insertData = [
['name' => 'Robert', 'surename' => 'Wolders', 'age' => '57'],
['name' => 'Jan', 'surename' => 'Vercauteren', 'age' => '51'],
['name' => 'Rutger', 'surename' => 'Hauer', 'age' => '61'],
['name' => 'Herbert', 'surename' => 'West', 'age' => '47']
];
foreach ($insertData as $row) {
$this->table->insert($row)->execute();
}
$test->count()->execute();
$test->count()->where('surename', '=', 'Vercauteren')->where('age', '>', '0')->execute();
$test->select(['name', 'age'])->execute();
$test->update(['name' => 'aaa'])->where('name', '=', 'Abaddon')->execute();
$test->delete()->where('surename', '=', 'Vercauteren')->execute();