0
1

More than 3 years have passed since last update.

PHP Eloquentライブラリを勉強しています

Posted at

PHP Eloquentライブラリの勉強を始めました。
今回はmydbというデータベースのjobsテーブルに接続する方法です。

DB接続

require_once './vendor/autoload.php';

$db = new Illuminate\Database\Capsule\Manager;

$db->addConnection
    ([

        'driver' => 'mysql',

            'host' => 'localhost',

        'database' => 'mydb',

            'username' => 'root',

            'pasword' => ''

    ]);

    $db->setAsGlobal();

      $db->bootEloquent();

class Jobs extends Illuminate\Database\Eloquent\Model {
    }

    $results = Jobs::all();

SQL文なしに全レコードを表示できます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1