1. Go to this page and download the library: Download cycle/database 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/ */
cycle / database example snippets
declare(strict_types=1);
Cycle\Database\DatabaseManager;
$dbm = new DatabaseManager(new Config\DatabaseConfig([
'databases' => [
'default' => ['connection' => 'sqlite'],
],
'connections' => [
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\FileConnectionConfig(
database: 'runtime/database.db'
),
),
],
]));
$users = $dbm->database('default')->table('users');
// create or update table schema
$schema = $users->getSchema();
$schema->primary('id');
$schema->string('name');
$schema->datetime('created_at');
$schema->datetime('updated_at');
$schema->save();
// insert data
$users->insertOne([
'name' => 'test',
'created_at' => new DateTimeImmutable(),
'updated_at' => new DateTimeImmutable(),
]);
// select data
foreach ($users->select()->where(['name' => 'test']) as $u) {
print_r($u);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.