1. Go to this page and download the library: Download schrosis/blade-sql 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/ */
use Schrosis\BladeSQL\Facades\BladeSQL;
use App\Moldes\Todo;
use App\Entities\YourTodoEntity;
$stdClassCollection = BladeSQL::select('todos.select');
// to model collection
$modelCollection = $stdClassCollection
->model(Todo::class); // or model(new Todo())
// to entity collection
$entityCollection = $stdClassCollection
->entity(YourTodoEntity::class);
class YourTodoEntity
{
private $id;
private $contents;
private $finished_at;
private $created_at;
public static fromArray(array $data)
{
// some code
}
}
// Same string value as the argument of DB::connection()
BladeSQL::setConnection('mysql::write')->update('users.change-password', $queryParams);
// or
// Accept ConnectionInterface
$connection = DB::connection('mysql::write');
BladeSQL::setConnection($connection)->update('users.change-password', $queryParams);