1. Go to this page and download the library: Download frootbox/db 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/ */
frootbox / db example snippets
use Frootbox\Db\Db;
use Frootbox\Db\Dbms\Mysql;
$db = new Db(new Mysql(
host: 'localhost',
schema: 'app',
user: 'app',
password: 'secret',
));
namespace App\Persistence;
use Frootbox\Db\Row;
class Page extends Row
{
protected $table = 'pages';
protected $model = Pages::class;
public function getTitle(): ?string
{
return $this->getAttribute('title');
}
public function setTitle(?string $title): static
{
return $this->setAttribute('title', $title);
}
public function isVisible(): bool
{
return !empty($this->getAttribute('isVisible'));
}
}
use Frootbox\Db\Conditions\Greater;
use Frootbox\Db\Conditions\Like;
$result = $pages->fetch([
'where' => [
new Greater('id', 10),
new Like('title', '%About%'),
],
]);