Tartalomjegyzék

< Composer

Composer illuminate/database

Illuminate/Database

A Laravel Illuminate/Database komponense használható a Laraveltől függetlenül is.

Telepítés

composer require illuminate/events
composer require illuminate/database

Példaprogram

src/Database/Example.php
<?php
 
require_once __DIR__.'/../../vendor/autoload.php';
 
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
 
$capsule = new Capsule;
$capsule->addConnection([
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => 'triangle',
    'username' => 'triangle',
    'password' => 'titok',
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
]);
 
$capsule->setEventDispatcher(new Dispatcher(new Container));
$capsule->setAsGlobal();
$capsule->bootEloquent();
echo Capsule::table('areas')->where('id', 1)->get();
echo  Capsule::table('areas')->get();
Capsule::table('areas')->insert(['area' => 400]);

Forrás